Ready to Level-Up?

This just in! If your rusty iOS skills could use some refining, or if you're just starting out and you want to level-up fast, consider signing up for our upcoming iOS Screencasts

New from iOS Rocket Surgery Swift Video Tutorials: The rapidly evolving Apple-iOS ecosystem has just been thrown into tumult with the recent introduction of the Swift Programming Language. Are you ready to finally try iOS development? Are you needing to switch from Objective-C to Swift? Sign up today for our free video courses!
(By the dear folks at Swift Tutorial Videos, a sister company)

Monday, December 16, 2013

How to Thread Sleep in iOS

So, you want to pause the execution of a thread for a moment, eh?

Whether you're creating your own timer, or regularly checking on completion of another task before proceeding in some segment of code, you'll most likely find putting a thread to sleep is a good solution, if not the best solution for such circumstances.

You can put a thread to sleep in one of two ways:

// Until one minute from now
[NSThread sleepUntilDate: [NSDate dateWithTimeIntervalSinceNow:60.0f]];

// Just sleep for 1 second

[NSThread sleepForTimeInterval:1.0f];

Now, you're on your way to snoozing your threads like the best of them.

About Me

Easy NSDateFormatter Tool

Save yourself some time in formatting your NSDates to NSStrings, and use the Blind NSDate app, which you can download from iTunes. There's also a website where you can format your NSDates:

Popular Posts

Designed By Seo Blogger Templates