Tutorial by Examples

This will create a timer to call the doSomething method on self in 5.0 seconds. [NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(doSomething) userInfo:nil repeats:NO]; Setting the repeats parameter to false/NO indicates that we...
[timer invalidate]; timer = nil; This will stop the timer from firing. Must be called from the thread the timer was created in, see Apple's notes: You must send this message from the thread on which the timer was installed. If you send this message from another thread, the input source associ...
[timer fire]; Calling the fire method causes an NSTimer to perform the task it would have usually performed on a schedule. In a non-repeating timer, this will automatically invalidate the timer. That is, calling fire before the time interval is up will result in only one invocation. In a repeat...
When creating a timer, you can set the userInfo parameter to include information that you want to pass to the function you call with the timer. By taking a timer as a parameter in said function, you can access the userInfo property. NSDictionary *dictionary = @{ @&quo...

Page 1 of 1