用类方法NSThread?

时间:2010-04-02 16:45:41

标签: cocoa nsthread

是否可以在单独的线程中运行类方法(以'+'开头)?通常我称之为[myClass myController];的方法我尝试了[NSThread detachNewThreadSelector:myController toTarget:myClass withObject:nil];但没有成功。

1 个答案:

答案 0 :(得分:9)

是的,您只需要制作目标[myClass class]而不是myClass。此外,您忘记在选择器名称周围使用@selector()。所以你想要:

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