Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
311 views
in Technique[技术] by (71.8m points)

ios - Issue with Google Analytics in Swift 2 or 3

I have a problem with Swift 2 (Swift 3) and Google Analytics.

This is the line with the problem:

tracker.send(GAIDictionaryBuilder.createScreenView().build())

Xcode tell's me:

Cannot invoke 'send' with an argument list of type '(NSMutableDictionary!)'

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Update for Swift 3 (2016.10.19)

let tracker = GAI.sharedInstance().defaultTracker
let build = (GAIDictionaryBuilder.createScreenView().build() as NSDictionary) as! [AnyHashable: Any]
tracker?.send(build)

Still an ugly approach, let me know if there's an cleaner conversion.


Original

Same here, struggling to resolve tons of errors.

What I did (deprecated):

var build = GAIDictionaryBuilder.createAppView().build() as [NSObject : AnyObject]
tracker.send(build)

Edit (2015)

Thanks to @George Poulos. . Recently they updated the options, now createAppView is deprecated, should use createScreenView instead.

var build = GAIDictionaryBuilder.createScreenView().build() as [NSObject : AnyObject]
tracker.send(build)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...