可能重复:
如何退出 NSThread
我已经使用 NSthread 调用了一个方法。我想在按钮的单击事件上停止线程。我怎样才能做到这一点?
[NSThread detachNewThreadSelector:@selector(playVideo) toTarget:self withObject:nil];
可能重复:
如何退出 NSThread
我已经使用 NSthread 调用了一个方法。我想在按钮的单击事件上停止线程。我怎样才能做到这一点?
[NSThread detachNewThreadSelector:@selector(playVideo) toTarget:self withObject:nil];
尝试 Threading 的文档,或者更好地使用在 viewControllerNSOperation
中执行playVideo
维护对操作的引用并向操作发送cancel
消息。参考文档NSOperation 文档