views:

138

answers:

2
+1  Q: 

Timer invalidate

What is the meaning of this statement given?

NSTimer *timer ,[timer invalidate]
+3  A: 

It's an objective C timer statement that cancels a running timer.

Normally it would be expressed as:

NSTimer* myTimer = [NSTimer timerWithTimeInterval:1.0 target:self
                                             selector:@selector(calculateTLE) userInfo:nil repeats:YES];
    [[NSRunLoop currentRunLoop] addTimer:myTimer forMode: NSDefaultRunLoopMode];

..

[myTimer invalidate];
Chaos
+1  A: 

It looks as though you're creating an instance of NSTimer without defining it, and then in the same line for whatever reason stopping that same timer. Waste of memory allocation resources, unless you're planning to use the timer at a later time, in which case you should trigger the timer then.

SeniorShizzle
Did any of these answer your question? They are all pretty thorough answers so if you wouldn't mind, a lot of us would be thankful if you would take the time to select the most helpful and accept it.
SeniorShizzle