ASINetworkQueue:尝试在已释放的委托上执行选择器
我正在使用来自的示例代码 https://gist.github.com/150447
当视图控制器卸载时,我将网络队列设置为nil,并调用重置方法。[[self networkQueue1]重置];
[自我设置NetworkQueue1:nil];
但一旦我返回到以前的视图控制器,我仍然会遇到异常。
* -[myViewController PerformSelector:withObject:]:消息发送到已释放的实例 0xc1d1bb0
请提出问题所在。
谢谢,
I am using the sample code from
https://gist.github.com/150447
when the viewcontroller unloads, im setting the networkqueue to nil, and also calling the reset method.
[[self networkQueue1] reset];
[self setNetworkQueue1:nil];
but still i get exception as soon as i go back to previous view controller.
* -[myViewController performSelector:withObject:]: message sent to deallocated instance 0xc1d1bb0
Please suggest whats going wrong.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要在 dealloc() 方法或更早的方法中将所有委托清零。根据您要设置的委托等,应该这样做:
基本上,您需要确保委托在销毁之前删除任何当前请求 - 这将确保释放的委托永远不会被调用。
You need to nil any delegates in the dealloc() method or earlier. Depending on exactly which delegates etc you're setting, something like this should do it:
Basically, you need to make sure the delegate is removed any current request before the delegate is destroyed - this will make sure that a deallocated delegate will never get called.
请参阅这篇文章
基本上,一个对象仍然具有对视图控制器的引用(可能因此它可以对其进行回调),并且当您返回到以前的 VC,当前的 VC 正在被释放(正如它应该的那样)。您需要找到该对象,并将其对您的 VC 的引用清零(可能称为“委托”或“回调”)。
希望有帮助。
Please see this post NSURLConnection gives EXC BAD ACCESS when tap on other tab while data loading
Basically, an object still has a reference to your view controller (probably so it can do a callback to it), and when you go back to the previous VC, the current VC is being deallocated (as it should.) You need to find that object, and nill out it's reference to your VC (probably called "delegate" or "callback").
Hope that helps.