我正在尝试在 Google Analytics 中为我的应用程序使用异常跟踪。 https://developers.google.com/analytics/devguides/collection/ios/v3/exceptions
我只是想弄清楚 Swift 中的语法(对 Obj-C 不太熟悉):
@try {
// Request some scores from the network.
NSArray *highScores = [self getHighScoresFromCloud];
}
@catch (NSException *exception) {
// May return nil if a tracker has not already been initialized with a
// property ID.
id tracker = [[GAI sharedInstance] defaultTracker];
[tracker send:[[GAIDictionaryBuilder
createExceptionWithDescription:@"Connection timout %d: %@", connectionError, errorDescription // Exception description. May be truncated to 100 chars.
withFatal:@NO] build]]; // isFatal (required). NO indicates non-fatal exception.
}
我已经设置好我的跟踪器,它可以很好地将其他数据保存到 GA,这只是createExceptionWithDescription()
我不确定的 Swift 中调用的语法。
使用 Swift 进行 Google Analytics(分析)的示例/文档似乎并没有太多... =/ 如果您知道,请告诉我!
谢谢。