- (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
网友评论