1
我试图使用V3 SDK将商业交易数据发送到iOS上的谷歌分析。我正在使用Google提供的GAIDictionaryBuilder类构建数据字典(不幸的是,这不是开源的)。对于createTransactionWithId和createItemWithTransactionId调用,我的NSNumber值(收入,价格等)未能正确添加到字典数据中。下面是示例代码:GAIDictionaryBuilder无法获取NSNumber值
NSMutableDictionary* test = [[GAIDictionaryBuilder createTransactionWithId:(NSString *)transactionId
affiliation:(NSString *)affiliation
revenue:(NSNumber *)revenue
tax:(NSNumber *)tax
shipping:(NSNumber *)shipping
currencyCode:(NSString *)currencyCode] build];
NSLog(@"revenue: %@", revenue);
NSLog(@"TR data: %@", test);
// if I explicitly set the value, IT WORKS!!!!
[test setObject:revenue forKey:@"&tr"];
NSLog(@"TR data FIXED??: %@", test);
在输出中,我看到收入正确,那么当记录测试字典我看到对应于收入数据以下行:
"&tr" = "<null>";
然后,对于手工修复尝试,我看到
"&tr" = "15.25";
如预期。
这里有一些线索:
- 我使用相同的代码在不同的OSX机器没有任何像这样的问题,编制了不同的项目。
- 交易是TRY(土耳其里拉),我怀疑谷歌正试图修复分隔符(','土耳其对其他地方'。'),但如上所述,另一个应用程序也使用TRY。
所以问题是,为什么"<null>"
,为什么以及如何将一个合适的NSNumber转换为这个奇怪的值?