In general, UIKit is not thread safe. Although you can “get away” with some things, you should always do UIKit things in the main thread. There are several well-documented exceptions.
The template for this from the background thread is simple.
dispatch_async(dispatch_get_main_queue(), ^{
The code inside the block that you pass dispatch_async will be scheduled to run in the main run loop.
source share