1

Right now I'm sleeping my main thread in order to have my application pause before running an action. [NSThread sleepForTimeInterval:0.75];. I know that that is less than ideal from a programming perspective, what other options do I have?

Peter Kazazes
  • 3,600
  • 7
  • 31
  • 60

2 Answers2

4

You could call the selector after a delay.

[self performSelector:@selector(yourAction:) withObject:nil afterDelay:0.75];
Paul Tiarks
  • 1,881
  • 1
  • 13
  • 10
3

For applications targeted for devices with iOS 4.0 or greater you could use Grand Central Dispatch:

  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, SecondsToWait*NSEC_PER_SEC), dispatch_get_current_queue(), ^{
                // And Call Your Action Here.
            });
Paul N
  • 1,901
  • 1
  • 22
  • 32