Many of the posts say that UIKit is totally not thread safe. Now on Apple documentation for GCD we can read that it\'s the DRAWING that is not thread safe. So would code lik
My personal opinion is that what you have heard so far is misleading.
Here is a quote from Apple's UIKit Framework Reference, credit to a similar thread here:
Note: For the most part, UIKit classes should be used only from an application’s main thread. This is particularly true for classes derived from UIResponder or that involve manipulating your application’s user interface in any way.
Also, note, that starting from iOS4, contrary to what you have assumed, according to release notes found here,
Drawing to a graphics context in UIKit is now thread-safe. Specifically:
- The routines used to access and manipulate the graphics context can now correctly handle contexts residing on different threads.
- String and image drawing is now thread-safe.
- Using color and font objects in multiple threads is now safe to do.
In fact furthermore in WWDC 2012 session "Building Concurrent User Interfaces", Apple engineer demonstrates drawing into image graphics context in a background thread.
My take-away:
In this example, you're not changing any values so yes,it's ok. Updating UI from background thread is not.