昨天在项目中遇到一个bug,就是在ios 10.1.1的系统上会有下边的崩溃,但是在10 11及其以上就没有任何事情(猜测可能是苹果帮我们做了错误处理):
错误日志:An instance 0x10a44ba50 of class LeeTagItem was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x174422cc0> ( <NSKeyValueObservance 0x17444bdf0: Observer: 0x10a44ba50, Key path: selected, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x170852ed0>
问题分析:
因为集成了第三方的一个控件,xcode不知道为什么没有获取到错误日志,后来再友盟后台拿到了上边的错误日志。看了日志后知道是项目中某处使用了KVO没有移除导致的,找见后在deallc中移除KVO就可以了。
- (void)dealloc{
[self removeObserver:self forKeyPath:@"key1"];
}