当线程 NSURLConnection 打开时弹出堆栈后崩溃
错误日志说: bool _WebTryThreadLock(bool), 0x3c689f0: 尝试从主线程或 Web 线程以外的线程获取 Web 锁。这可能是从辅助线程调用 UIKit 的结果。现在崩溃...
应用程序结构: 当通过用户交互需要新数据时,工作线程与主线程分离,每个工作线程将数据输入到数组中自己的槽中。仅当我使用 NavigationController“返回”到上一个视图而线程仍在收集数据时,才会出现问题。我尝试在 viewWillDisappear 上向每个线程发送 [NSThread exit] ,但这不起作用...
有关弹出视图控制器时线程清理的任何建议吗?
Error Log says:
bool _WebTryThreadLock(bool), 0x3c689f0: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...
App structure:
worker threads are detached from the MainThread as new data is needed via user interaction, each worker thread feeds data into its own slot in an array. The problem arises only when I use the NavigationController to go "back" to the previous view WHILE a thread is still gathering data. I've tried to send a [NSThread exit] to each thread upon viewWillDisappear thats not going to work...
Any suggestions on thread clean-up upon poppin' the view controller?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因此,显然我需要构建对 runloop 以及 didRecieveData 循环的检查,以监视全局变量以指示视图是否已消失。这反过来需要切换全局变量,导致所有打开的线程取消连接并退出线程。
So apparently i needed to build in checks to the runloop as well as the didRecieveData loop to watch for a global variable to indicate if the view has disappeared. This in turn needs to toggle the global var, causing all open threads to cancel the connection as well as exit the thread.