完美地使用
Swift 1.2
代码:
var build = GAIDictionaryBuilder.createEventWithCategory("Record Counter",action: "Images Taken",label: "usersad",value: 1 ).build() as [NSObject : AnyObject] self.tracker.send(build)
错误:
NSMutableDictionary is not convertible to [NSObject : AnyObject]
任何的想法?
解决方法
你错了你的事件.这是正确的方法和一种方法.
let tracker = GAI.sharedInstance().defaultTracker
将事件跟踪器初始化为NSObject
let eventTracker: NSObject = GAIDictionaryBuilder.createEventWithCategory( "ui_action",action: "button_press",label: "play",value: nil).build()
在发送方法中将NSObject转换为Anyobject.
tracker.send(eventTracker as! [NSObject : AnyObject])