Skip to content
This repository was archived by the owner on Mar 3, 2020. It is now read-only.
This repository was archived by the owner on Mar 3, 2020. It is now read-only.

self.KVOControllerNonRetaining observe:self crash #140

@GitHubXuLiying

Description

@GitHubXuLiying

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);
}];

  • (void)dealloc {
    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>
)'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions