NSThread with class method?

Is it possible to run a class method (starting with "+") in a separate thread? I usually call a method like [myClass myController]; I tried [NSThread detachNewThreadSelector:myController toTarget:myClass withObject:nil]; without success.

+4
source share
1 answer

Yes, you just need to make the target [myClass class] instead of myClass . Also, you forgot to use @selector() around the selector name. So you want:

[NSThread detachNewThreadSelector:@selector(myController) toTarget:[myClass class] withObject:nil];

+9
source

Source: https://habr.com/ru/post/1305860/


All Articles