I have an application where the content is displayed to the user. Now I want to know how many seconds the user is viewing this content. So in my header file I declared
NSDate *startTime; NSDate *endTime;
Then in my view, willappear
startTime = [NSDate date];
Then in my view, WillDisappear
endTime = [NSDate date]; NSTimeInterval secs = [endTime timeIntervalSinceDate:startTime]; NSLog(@"Seconds --------> %f", secs);
However, the application sometimes crashes. Sometimes it is a memory leak, sometimes it is a problem with NSTimeInterval, and sometimes it crashes after returning to the content a second time.
Any ideas on fixing this?
ios nsdate nstimeinterval
Adam Altinkaya Nov 01 '13 at 9:59 2013-11-01 09:59
source share