NSTimer invalidation
If I create a timer which never repeats
[NSTi开发者_运维问答mer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(updateSystems) userInfo:nil repeats:NO];
do I still need to invalidate it?
Also, is releasing the instance one step in the invalidate method? Since I'm not using alloc my timer variable shouldn't have to be released, although when creating a timer it automatically should create a new thread? Does the timer still add up on the stack? I need some clarity.
Thank you
See the documentation for the method. It says:
repeats
If YES, the timer will repeatedly reschedule itself until invalidated. If NO, the timer will be invalidated after it fires.
You are not creating any pointer to NSTimer. You are using it directly through a class method. This method does not creates a new instance of NSTimer so you don't have to release it.
精彩评论