Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Merge pull request #17 from kreeger/feature/swift-1.2-support
Browse files Browse the repository at this point in the history
Initial stab at Swift 1.2 support.
  • Loading branch information
hsoi committed May 6, 2015
2 parents f571bd3 + d870baa commit 91d1170
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion HEAnalytics/HEAnalytics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public class HEAnalytics: NSObject {
configDict.enumerateKeysAndObjectsUsingBlock({ (key:AnyObject!, value:AnyObject!, stop:UnsafeMutablePointer<ObjCBool>) -> Void in
if let keyString = key as? String {
if let valueDictionary = value as? [NSObject:AnyObject] {
let theClass = NSClassFromString(keyString) as HEAnalyticsPlatform.Type
let theClass = NSClassFromString(keyString) as! HEAnalyticsPlatform.Type
let platform = theClass(platformData: valueDictionary)
self.platforms.append(platform)
}
Expand Down
10 changes: 6 additions & 4 deletions HEAnalytics/HEAnalyticsPlatformGAI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ class HEAnalyticsPlatformGAI: HEAnalyticsPlatform {
#endif
}

let trackingID = platformData["trackingID"] as String
GAI.sharedInstance().trackerWithTrackingId(trackingID)
if let trackingID = platformData["trackingID"] as? String {
GAI.sharedInstance().trackerWithTrackingId(trackingID)
}

if let dryRun = platformData["dryRun"] as? Bool {
GAI.sharedInstance().dryRun = dryRun
Expand Down Expand Up @@ -114,7 +115,8 @@ class HEAnalyticsPlatformGAI: HEAnalyticsPlatform {
if let dataParameters = data.parameters {
JSONString = HEJSONHelper.canonicalJSONRepresentationWithObject(dataParameters)
}
GAI.sharedInstance().defaultTracker.send(GAIDictionaryBuilder.createEventWithCategory(data.category, action:data.event, label:JSONString, value:nil).build())
let sendData = GAIDictionaryBuilder.createEventWithCategory(data.category, action:data.event, label:JSONString, value:nil).build()
GAI.sharedInstance().defaultTracker.send(sendData as [NSObject: AnyObject])
}


Expand All @@ -126,7 +128,7 @@ class HEAnalyticsPlatformGAI: HEAnalyticsPlatform {
let tracker = GAI.sharedInstance().defaultTracker
let title = self.viewControlerTitle(viewController)
tracker.set(kGAIScreenName, value: title)
tracker.send(GAIDictionaryBuilder.createScreenView().build())
tracker.send(GAIDictionaryBuilder.createScreenView().build() as [NSObject: AnyObject])
}

}
5 changes: 3 additions & 2 deletions HEAnalytics/HEAnalyticsPlatformMixpanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ class HEAnalyticsPlatformMixpanel: HEAnalyticsPlatform {
defaultFlushInterval = flushInterval
}

let token = platformData["token"] as String
self.mixpanel = Mixpanel(token: token, launchOptions: nil, andFlushInterval: defaultFlushInterval)
if let token = platformData["token"] as? String {
self.mixpanel = Mixpanel(token: token, launchOptions: nil, andFlushInterval: defaultFlushInterval)
}

if let flushOnBackground = platformData["flushOnBackground"] as? Bool {
self.mixpanel.flushOnBackground = flushOnBackground
Expand Down
6 changes: 4 additions & 2 deletions HEAnalytics/HEJSONHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,10 @@ public class HEJSONHelper: NSObject {
var keys = sorted(dictionary.keys) {
(obj1, obj2) in

let s1 = obj1 as String
let s2 = obj2 as String
// NOTE: These forced casts should not fail, but if they do, we'll need to find
// another solution.
let s1 = obj1 as! String
let s2 = obj2 as! String
return s1 < s2
}

Expand Down

0 comments on commit 91d1170

Please sign in to comment.