If my instance is observing some property of another object, am I supposed to call removeObserver:forKeyPath: in dealloc?
Asked
Active
Viewed 2,308 times
2 Answers
10
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.

justin
- 104,054
- 14
- 179
- 226
3
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

Community
- 1
- 1

Parag Bafna
- 22,812
- 8
- 71
- 144