I set up a notification observer in my view controller's init
method like so:
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(saveState)
name:UIApplicationWillResignActiveNotification
object:nil];
Where is the best place to call removeObserver:name:object:
for this notification. I'm currently calling it in my dealloc
method, but wanted to know if that might cause problems.
No, you got it right. dealloc
is the correct location to remove notification observers (unless you have some specific reason to need to remove the observer earlier).
You can always remove the observer in viewWillDisappear:
, or when you are done using it and have no other need for it, you can place it in a function.
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