-
Notifications
You must be signed in to change notification settings - Fork 924
self.KVOControllerNonRetaining observe:self crash #140
Comments
I am seeing the exactly same issue with KVOControllerNonRetaining prior to macOS 10.12 on binaries build on macOS 10.14. No issue on 10.13 and 10.14 though. Looking at the header for
Note the prior in the above. If we are observing Note that this is different to vanilla KVO. The reason for this is that the reference to The funky part seems to be that the Cocoa KVO machinery post 10.12 seems to be able to tolerate the surviving observation during So personally I would consider |
Same issue here, on iOS 10.3.3. |
I also encountered this problem, but i see a answer above |
Add the code below and it works fine:
|
System version less than iOS 11
[self.KVOControllerNonRetaining observe:self keyPath:@"name" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld block:^(id _Nullable observer, id _Nonnull object, NSDictionary<NSString *,id> * _Nonnull change) {
NSLog(@"xly--%@",change);
}];
NSLog(@"xly--%@",@"dealloc");
[self.KVOControllerNonRetaining unobserveAll];
}
pop crash
2018-10-17 14:40:41.390 TestField[71971:8049984] xly--dealloc
2018-10-17 14:40:45.767 TestField[71971:8049984] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x7fa168e04230 of class TestViewController was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x60000003a4c0> (
<NSKeyValueObservance 0x608000244470: Observer: 0x60800009bda0, Key path: name, Options: <New: YES, Old: YES, Prior: NO> Context: 0x60800007ffc0, Property: 0x6080002422e0>
)'
The text was updated successfully, but these errors were encountered: