I have a NSTimer running with scheduled time interval 1.Here I am keep tracking the current Time as given below.
- (void)myMethod:(NSTimer*)timer {
NSDate *startDate = [[[NSDate alloc] init] autorelease];
}
on some notification I am trying to find the difference between before and after time change.
-(void) handleNotification: (NSNotification*) notification
{
NSTimeInterval elapsedTimeInterval = [startDate timeIntervalSinceNow];
}
Here I am getting EXC_BAD_ACCESS.
If I use startDate = [[NSDate date] retain]; no crash,didn’t understand where to release startDate as I am invalidating this timer on dealloc.
Note:can’t use properties since need to support 10.4.
Regards,
Akbar
One way is to release the previous value and assign the new one.
1 Assign the value like this,
2 Retrieve the value as usual,
3 Finally release it in dealloc method.