Where should I remove a notification observer?

Posted by nevan on Stack Overflow See other posts from Stack Overflow or by nevan
Published on 2011-01-13T21:40:27Z Indexed on 2011/01/14 1:54 UTC
Read the original article Hit count: 271

I set up a notification observer in my view controll 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.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c