xcode - Objective-C invalidate timer in another method -


I have a way in which I have declared a timer;

  - (zero) StartTimer: (ID) Sender {NSTimer * timer = [NSTimer Scheduled Timer with Time Interval: 0.8 Targets: Self Selector: @Selector (Toggle Button :) User Information: Zero Repeats: Yes]; }   

What do I want to do, in another method, I want to invalidate the timer if it is running, then whatever I have done here, but timer unannounced me 'Error' - (zero) stop timer: (id) sender {if ([timer is invalid]) {[timer invalid], timer = zero; }}

Can anyone help me?

If both methods are on the same controller, then just to make the timer an example variable If they are not on the same object, then you should consider your design again because the two classes are trying to manage the same feature.

Comments