为了在 iPhone 应用程序中实现 Omniture 跟踪,我从 SiteCatalyst (AppMeasurement.h,libAppMeasurement.a,libAppMeasurementNoThumb.a) 下载了 AppMeasurement 软件。
我正在使用 Omniture 的应用程序测量 iphone 库,链接了发布库和开发库。我使用单例方法 (getInstance) 实例化它们。实现如下
#import "OmnitureTracking.h"
#import "AppMeasurement.h"
AppMeasurement *s = nil;
@implementation OmnitureTracking
+ (void)beginTracking {
s = [[AppMeasurement getInstance] retain];
s.account = @"";
s.debugTracking = YES;
}
在 AppDelegate 中调用此“beginTracking”来启动跟踪,对于 pagetracking 实现了另一种方法,如下所示:
+ (void)trackViewForPage:(NSString *)pageName {
NSLog(@"trackViewForPage::s instance::%@::",s);
if (s == nil)
return;
[s clearVars];
[s track:[NSDictionary dictionaryWithObjectsAndKeys:pageName, @"pageName", nil]];
}
实施工作正常并低于日志:
2012-06-21 01:53:20.953 MyApp[857:607] App Measurement Library compile time = Aug 4 2011 16:29:52
2012-06-21 01:53:21.418 MyApp[857:607] trackViewForPage::s instance::<AppMeasurement: 0x28c4b0>::
2012-06-21 01:53:21.795 MyApp[857:607]
Omniture App Measurement Debug: http://MyApp.net/b/ss/MyAppiosappdev/0/OIP-2.1.2/s2253418?AQB=1&ndh=1&t=21/5/2012%205%3A53%3A20%204%20240&vid=01398194867219045&ce=UTF-8&pageName=MyApp%201.2%20%281.2%29%20Launch&ts=2362139876678&events=event7%2Cevent5&c1=D%3Dv2&c2=D%3Dv6&c3=D%3Dv11&v2=MyApp%201.2%20%281.2%29&v4=0&v5=0&v6=20&v7=5&v8=Thursday&v9=4.3.3&v12=D%3Dv3&v13=D%3Dv3&s=320x480&c=24&AQE=1
但是当应用程序进入后台并进入前台时,应用程序由于跟踪和获取日志而崩溃,如下所示:
Jun 21 03:07:41 unknown MyApp[467] <Warning>: trackViewForPage::s instance::(
""
)::
Jun 21 03:07:41 unknown MyApp[467] <Error>: -[__NSCFArray clearVars]: unrecognized selector sent to instance 0x28c4b0
Jun 21 03:07:41 unknown MyApp[467] <Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray clearVars]: unrecognized selector sent to instance 0x28c4b0'
当应用程序进入后台并进入前台时,“AppMeasurement”实例变为 nil 或为空,但我无法确定它是 Site Analyst iPhone 库问题还是编码问题。
为了处理崩溃,我做了零检查,但它没有落入零情况。
请帮助我弄清楚“AppMeasurement”实例空检查以及为什么当应用程序进入后台并进入前台时“AppMeasurement”实例变为空。
谢谢