2015-04-12 45 views
12

工作,我試圖用Google Analytics與我的雨燕1.2的應用程序使用Xcode的6.3beta。谷歌分析不雨燕1.2和6.3的Xcode

我的橋接頭正常工作,幷包含:

#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" 

我嘗試以下斯威夫特代碼來跟蹤頁面:

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 SwiftUsing Google Analytics with Swift on iOS

我有什麼改變,使上面雨燕1.2使用的代碼?

回答

24

我有同樣的問題。這是我如何得到它的工作

let build = GAIDictionaryBuilder.createAppView().set(screenName, forKey: kGAIScreenName).build() as NSDictionary 
tracker.send(build as [NSObject : AnyObject]) 
+4

'as [NSObject:AnyObject]'就夠了 –

+0

createScreenView() –