如何在iPhone中停止NSThread? [英] How to stop a NSThread in iphone?

查看:70
本文介绍了如何在iPhone中停止NSThread?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
如何退出NSThread

Possible Duplicate:
How to exit NSThread

我已经使用NSthread调用了一个方法.我想在按钮的click事件上停止线程.我该如何实现?

I have called a method using NSthread. I want to stop the thread on a click event of button. How can I achieve that?

[NSThread detachNewThreadSelector:@selector(playVideo) toTarget:self withObject:nil]; 

推荐答案

尝试

Try the the documentation for Threading, or better yet use NSOperation to perform the playVideo maintain a reference to the operation in your viewController and send a cancel message to the operation. Refer to the documentationNSOperation documentation

这篇关于如何在iPhone中停止NSThread?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆