gpt4 book ai didi

cocoa - NSThread 带有类方法?

转载 作者:行者123 更新时间:2023-12-03 16:12:37 25 4
gpt4 key购买 nike

是否可以在单独的线程中运行类方法(以“+”开头)?通常我调用像 [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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com