是否可以在单独的线程中运行类方法(以“+”开头)?通常我调用像 [myClass myController];
这样的方法,我尝试了 [NSThread detachNewThreadSelector:myController toTarget:myClass withObject:nil];
但没有成功。
最佳答案
是的,您只需创建目标[myClass class]
而不是myClass
。此外,您还忘记在选择器名称周围使用 @selector()
。所以你想要:
[NSThread detachNewThreadSelector:@selector(myController) toTarget:[myClass class] withObject:nil];
关于cocoa - NSThread 带有类方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2567886/