Closed xuzhenhao closed 8 years ago
There is KVOControllerNotRetaining
just for that... :)
You would need to add [self.KVOControllerNotRetaining unobserveAll]
in your dealloc
just to make sure nothing gets still observed when you are deallocating the object.
I would suggest refactoring your class, to avoid observation on self
, since you have full control over it and can override the property getter/setter to get the same behavior.
Let me know if this helps.
@nlutsenko When I added the [self.KVOControllerNotRetaining unobserveAll] in my dealloc . it crashed.. " was deallocated while key value observers were still registered with it "
It is an old thread but for @nlutsenko's and others information, the problem still persists in versions prior to iOS 11, even when you use self.KVOControllerNotRetaining
and call [self.KVOControllerNotRetaining unobservall]
in dealloc
. I think if you need to observe self
, it is not a good idea to do that with KVO or any 3rd party like this one. You just override the setter
method and you'll be good to go.
[self.KVOController observe:self keyPath:@"pages" options:NSKeyValueObservingOptionNew action:@selector(pagesDidChange:object:)];