4

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.

skaffman
  • 398,947
  • 96
  • 818
  • 769

1 Answers1

10

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

Nick Moore
  • 15,547
  • 6
  • 61
  • 83