Reputation: 2113
To Implement the Omniture Tracking in an iPhone Application, I have downloaded the AppMeasurement software from SiteCatalyst(AppMeasurement.h,libAppMeasurement.a,libAppMeasurementNoThumb.a).
I am using Omniture's app measurement iphone library, linked the release and dev libraries. I instantiate them using the singleton method (getInstance). Implemented as below
#import "OmnitureTracking.h"
#import "AppMeasurement.h"
AppMeasurement *s = nil;
@implementation OmnitureTracking
+ (void)beginTracking {
s = [[AppMeasurement getInstance] retain];
s.account = @"";
s.debugTracking = YES;
}
Calling this 'beginTracking' in AppDelegate to initiate the tracking, for pagetracking implemented another method as below:
+ (void)trackViewForPage:(NSString *)pageName {
NSLog(@"trackViewForPage::s instance::%@::",s);
if (s == nil)
return;
[s clearVars];
[s track:[NSDictionary dictionaryWithObjectsAndKeys:pageName, @"pageName", nil]];
}
Implementaion working fine and getting below log:
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
But when app goes background and enters foreground, app is crashing because of Tracking and getting the log as below:
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" instance becoming nil or empty when app goes background and enters foreground, but I am not able to figure out whether its the Site Analyst iPhone Library issue or Coding issue.
To handle the crash,I have done the nil check, but its not falling under nil case.
Please help me in figuring out the "AppMeasurement" instance empty check and why "AppMeasurement" instance becoming empty when app goes background and enters foreground.
Thanks
Upvotes: 0
Views: 2255
Reputation: 2113
Finally, i have figured out the things. Sorry for all the mishap.
All I am doing is using a 3rd party library to implement the Omniture Tracking for iPhone Application which is provided by Site Catalyst itself.
Please refer the below URL for library : Site Catalyst Omniture library is intended for apps developed for all iOS devices, including iPhone, iPad and iPod Touch
There is problem with the library itself, its having lot of memory management issues.
They have provided new library with the memory leakage fixes.
Uploaded the new libraries to fix the issue.
Got the issue at the supporting class - OmnitureTracking.m
, while setting the AppMeasurement.h
Property :
//Use best practices plugin
s.useBestPractices = YES;
Because of this property, omniture tracking got called whenever app comes to active state i.e. launches. As the libaries having memory management issue, app getting crashed when ever app goes background and comes foreground.
Thanks for the replies.
But still one thing haunting me is how to check the empty instance of a class
If instance is there, its getting on NSLog as
2012-06-21 01:53:21.418 MyApp[857:607] trackViewForPage::s instance::<AppMeasurement: 0x28c4b0>::
But in error case getting the instance on NSLog as
Jun 21 03:07:41 unknown MyApp[467] <Warning>: trackViewForPage::s instance::("")::
By seeing that , i am thinking it as EMPTY INSTANCE case. How to check this case? Its not checking under nil check.
Upvotes: 1
Reputation: 162722
That code is a mess; hard to say what is wrong for the reasons mentioned in the comments on your question.
no method should be prefixed with get
unless it is of a very special type
beginTracking
leaks whatever is assigned to s
So... s
is being assigned to an NSArray instance either because the poorly named getInstance
is returning an NSArray or you are over-releasing that object.
Upvotes: 0