Search code examples
objective-ctimerios4

sleepForTimeInterval Timeout freezes app


I'm trying to wait X amount of seconds in between actions. When using [NSThread sleepForTimeInterval:3.0]; the app freezes for the set amount of time. How can I timeout without disrupting the main thread?


Solution

  • You can't block the main runloop (which handles user input) and expect your app to remain responsive. Consider using an NSTimer.