开发者

NSThread with class method?

开发者 https://www.devze.com 2022-12-25 17:53 出处:网络
Is it possible to run a class method (starting with a \'+\') in a separate thread? N开发者_StackOverflow社区ormally I call the method like [myClass myController]; I tried [NSThread detachNewThreadSele

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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号