【发布时间】:2015-04-12 16:48:52
【问题描述】:
我尝试在使用 Xcode 6.3beta 的 Swift 1.2 应用程序中使用 Google Analytics。
我的桥接头工作正常并且包含:
#import "GAI.h"
#import "GAIDictionaryBuilder.h"
#import "GAIEcommerceFields.h"
#import "GAIEcommerceProduct.h"
#import "GAIEcommerceProductAction.h"
#import "GAIEcommercePromotion.h"
#import "GAIFields.h"
#import "GAILogger.h"
#import "GAITrackedViewController.h"
#import "GAITracker.h"
我尝试了以下 Swift 代码来跟踪页面:
var tracker2:GAITracker = GAI.sharedInstance().defaultTracker as GAITracker
tracker2.set(kGAIScreenName, value:"Home Screen")
tracker2.send(GAIDictionaryBuilder.createScreenView().build())
但上面的最后一行引发了以下错误:
Cannot invoke 'send' with an argument list of type '(NSMutableDictionary!)'
我发现了类似的问题,例如:Google Analytics not initialising in Swift、Using Google Analytics with Swift on iOS
要使上述代码与 Swift 1.2 一起使用,我需要进行哪些更改?
【问题讨论】:
标签: objective-c iphone swift google-analytics xcode6