If my instance is observing some property of another object, am I supposed to call removeObserver:forKeyPath: in dealloc?
Yes
...unless there is a more appropriate time earlier in execution.
Observers are held as nonretained references. Failing to un-register can result in your deallocated instance being messaged.
You need to use -removeObserver:forKeyPath: to remove the observer before -[NSObject dealloc] runs, so yes, doing it in the -dealloc method of your class would work.
refer this questions.
Removing an Observer
question2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With