Search code examples
iphoneobjective-ciosdelaynonblocking

How to perform several actions with non-blocking delay?


I need to put first image on screen, then put the second after 1 second, and then - the last one after one more second. Also, this should be done in non-blocking manner :) How do you perform that in such cases? Was thinking about nesting several UIView animateWithDuration class methods, but I do not need any animations, I just need to put several images on screen in straight manner with a delay after each step.

UPDATE: IMHO it's too heavyweight approach to use NSTimer for this simple problem. I should need to get a reference, schedule 3 different timers (or one with very if'y method) and then to stop somehow. If so, I would like to to it all from within one method. In that case, if I initiate timer with scheduledTimerWithTimeInterval then IMHO I need to stop (invalidate) somewhere else or smth?


Solution

  • Use NSObject's performSelector:withObject:afterDelay:.