开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜