美文网首页
KVO: BUG

KVO: BUG

作者: plantAtree_dAp | 来源:发表于2017-02-20 12:00 被阅读40次
- (void)viewDidLoad {
    [super viewDidLoad];

 if (self.resumeSourceType == 2){
        [self.myKVO addObserver: self forKeyPath: @"resmPercentage" options:NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew context: nil ];
    }

addObserver 与 removeObserver, 一定要 配套使用

- (void)dealloc{
    if (self.resumeSourceType == 2){
        [self.myKVO removeObserver: self forKeyPath: @"resmPercentage" context: nil ];
        
    }

}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    [self removeObserver: self forKeyPath: @"resmPercentage" context: nil ];
}



搞笑

TheStep[974:194090] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x170013f70 of class ResumeKVOModel was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x170437f40> (
<NSKeyValueObservance 0x170056770: Observer: 0x14794a520, Key path: resmPercentage, Options: <New: YES, Old: YES, Prior: NO> Context: 0x0, Property: 0x170640660>
)'

Œ
差一点

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    [self.myKVO removeObserver: self forKeyPath: @"resmPercentage" context: nil ];
}


TheStep[945:188975] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'An instance 0x174014620 of class ResumeKVOModel was deallocated while key value observers were still registered with it.

Current observation info: <NSKeyValueObservationInfo 0x17043ac80> (
<NSKeyValueObserv

相关文章

  • KVO: BUG

    addObserver 与 removeObserver, 一定要 配套使用  TheStep[974:19...

  • WMStickyPagecontroller

    1.在WMMagicScrollView的KVO回调有scrollView导致的Bug

  • iOS原理篇(一): KVO实现原理

    KVO实现原理 什么是 KVO KVO 基本使用 KVO 的本质 总结 一 、 什么是KVO KVO(Key-Va...

  • 04. KVO使用,原理,本质

    问题 KVO日常使用 KVO原理(KVO本质是什么) 如何手动触发KVO 直接修改成员变量会触发KVO吗 KVO图...

  • 20.iOS底层学习之KVO 原理

    本篇提纲1、KVO简介;2、KVO的使用;3、KVO的一些细节;4、KVO的底层原理; KVO简介 KVO全称Ke...

  • 深入理解KVO

    iOS | KVO | Objective-C KVO的本质是什么,如何手动触发KVO? 1.什么是KVO KVO...

  • OC语法:KVO的底层实现

    一、KVO是什么二、怎么使用KVO三、KVO的底层实现四、KVO常见面试题 一、KVO是什么 KVO全称Key-V...

  • KVO基本使用

    分三部分解释KVO一.KVO基本使用二.KVO原理解析三.自定义实现KVO 一、KVO基本使用 使用KVO,能够非...

  • KVO 解析

    KVO解析(一) —— 基本了解KVO解析(二) —— 一个简单的KVO实现KVO解析(三) —— KVO合规性K...

  • KVO

    目录 1. KVO的使用1.1 KVO基本使用方法1.2 KVO手动触发模式1.3 KVO属性依赖1.4 KVO容...

网友评论

      本文标题:KVO: BUG

      本文链接:https://www.haomeiwen.com/subject/rqgswttx.html