Code on the Main Thread?
Quick and easy to implement code to check to see if your code is running on the main thread or not, and if it isn't, in the case of UIKit events, switch to the main thread
BOOL isOnMainThread = [[NSThread currentThread] isEqual:[NSThread mainThread]];
if (!isOnMainThread)
{
dispatch_async(dispatch_get_main_queue(), ^{
[self callMethodAgainWithParams:aforelistedParams];
});
return;
}
Written by Max Kramer
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Objective-c
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#