What's the equivalent of Java's Thread.sleep() in Objective-C/Cocoa?

levi picture levi · May 6, 2009 · Viewed 93.8k times · Source

In Java you can suspend the current thread's execution for an amount of time using Thread.sleep(). Is there something like this in Objective-C?

Answer

smorgan picture smorgan · May 6, 2009

Yes, there's +[NSThread sleepForTimeInterval:]

(Just so you know for future questions, Objective-C is the language itself; the library of objects (one of them at least) is Cocoa.)