Invalidate non-repeating NSTimer after fired?

2012-08-03 Thread Trygve Inda
NSTimer* myTimer = [NSTimer scheduledTimerWithTimeInterval:60 target:self selector:@selector(wantsUpdate:) userInfo:nil repeats:NO] Sometime after it fires (and occasionally before), I call if ( myTimer ) { [myTimer invalidate]; [myTimer release]; myTimer = nil; } Should I really be

Re: Invalidate non-repeating NSTimer after fired?

2012-08-03 Thread Charlie Dickman
You must use the 2nd way. If you don't you could get a memory exception if the timer has fired and, therefore, been invalidated. On Aug 3, 2012, at 4:19 PM, Trygve Inda wrote: NSTimer* myTimer = [NSTimer scheduledTimerWithTimeInterval:60 target:self selector:@selector(wantsUpdate:)

Re: Invalidate non-repeating NSTimer after fired?

2012-08-03 Thread Lee Ann Rucker
Not if you've retained the timer - and if you haven't, then you shouldn't release it. Conversely if you *have*, you should release and nil it when it fires. On Aug 3, 2012, at 2:10 PM, Charlie Dickman wrote: You must use the 2nd way. If you don't you could get a memory exception if the

Re: Invalidate non-repeating NSTimer after fired?

2012-08-03 Thread Trygve Inda
You must use the 2nd way. If you don't you could get a memory exception if the timer has fired and, therefore, been invalidated. On Aug 3, 2012, at 4:19 PM, Trygve Inda wrote: My code looks like this: -(void)awakeFromNib { [self setUpdateTimer:[NSTimer

Re: Invalidate non-repeating NSTimer after fired?

2012-08-03 Thread Quincey Morris
On Aug 3, 2012, at 14:37 , Trygve Inda cocoa...@xericdesign.com wrote: I think B is the concern since if I change the code to: if ([updateTimer isValid]) [updateTimer invalidate]; Then it will be invalidated in case B (because the code has not fallen back to the run loop to invalidate