有没有办法检查当前线程是否是Objective-C中的主线程?
我想做这样的事情.
- (void)someMethod
{
if (IS_THIS_MAIN_THREAD?) {
NSLog(@"ok. this is main thread.");
} else {
NSLog(@"don't call this method from other thread!");
}
}
Run Code Online (Sandbox Code Playgroud)