iOS Development Journal

Tips and Tricks Learned the Hard Way

Verifying UIKit Is Running on the Main Thread

As previously mentioned: to get the UI to update, you need to run your UIKit configuring code on the main thread. Peter Stienberger has posted a great snippet of code that raises an assertion whenever you attempt to access UIKit code from off of the main thread. Simply add the file to your project (and swap out the PSPDFLogError with an NSLog) and build and run. Everytime you call UIKit code off of the main thread, it’ll crash your app. Great for finding bugs.