码迷,mamicode.com
首页 > 移动开发 > 详细

[UIActivityIndicatorView _applicationDidEnterBackground:]: message sent to deallocated instance

时间:2015-07-09 13:12:29      阅读:558      评论:0      收藏:0      [点我收藏+]

标签:uiactivityindicatorv   _applicationdidenter   message   sent   deallocated   

[UIActivityIndicatorView _applicationDidEnterBackground:]: message sent to deallocated instance


当我们运行我的的App 时,App不会crash,可当我们一按home 键,或者锁屏时,App 就会 crash  ,利用zombie 可以捕获如上信息。由信息中可得,app 向一个已经被释放的UIActivityIndicatorView发送了一个消息,导致crash。最后检查到原来是是使用的第三方包UIKit+AFNetWorking  导致的,

再   UIActivityIndicatorView+AFNetworking.m 中,有如下代码,


-(void)dealloc

{

    NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];

#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000

    [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil];

    [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil];

    [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil];

#endif

    

    [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil];

    [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil];

}


那就很明显了,当App 进入后台,UIActivityIndicatorView 被释放,当执行这个方法,App 便被crash了。

如果大家引入UIKit+AFNetWorking 时,没有用到UIActivityIndicatorView+AFNetworking ,大可把他移除掉,这样就可以解决上面的问题了。

希望对大家有帮助。


版权声明:本文为博主原创文章,未经博主允许不得转载。

[UIActivityIndicatorView _applicationDidEnterBackground:]: message sent to deallocated instance

标签:uiactivityindicatorv   _applicationdidenter   message   sent   deallocated   

原文地址:http://blog.csdn.net/pzhtpf/article/details/46814803

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!