Obj-C: performSelector instead of NSTimer
Often times I just want to delay a single call by a number of seconds. I don’t really want to loop it.
Previous I had used NSTimer to create the call, then I had to remove the time when the call was made. This was less than ideal, and more code that I would have liked. However, I’ve since discover the excellent ‘PerformSelector’:
To use:
[self performSelector:@selector(method) withObject:nil afterDelay:5.0];
To cancel:
[NSRunLoop cancelPreviousPerformRequestsWithTarget:self];
For more information, check out apples docs here: apple docs
