4

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

4

1 回答 1

10

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

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

于 2010-04-02T16:52:58.217 回答