¿Hay alguna manera de comprobar si el hilo actual es el hilo principal en Objective-C?Compruebe si el hilo actual es el hilo principal
Quiero hacer algo como esto.
- (void)someMethod
{
if (IS_THIS_MAIN_THREAD?) {
NSLog(@"ok. this is main thread.");
} else {
NSLog(@"don't call this method from other thread!");
}
}
¿Qué hay de malo en llamar a un método desde otros hilos? –