Jeroen Sterckx
Jeroen Sterckx

Reputation: 43

NSThread with class method?

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

Upvotes: 4

Views: 1082

Answers (1)

Nick Moore
Nick Moore

Reputation: 15857

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];

Upvotes: 10

Related Questions