Timer invalidate
What is the meaning of this statement given?
NSTim开发者_如何学JAVAer *timer ,[timer invalidate]
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];
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.
精彩评论