My AppDelegate class is registered for a particular notification like below
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applyThemeA:)
name:@"ThemeA"
object:nil];
}
And applyThemeA does ( just not much )
- (void)appleThemeA:(NSNotification*)notification {
NSLog(@"apply themeA");
}
I am placing removeObserver
in applicationWillTerminate
, but not so sure it is a good way for it.
Question
Is it a good place to place this method in.
I just wanna make sure I am doing the right way. If the question is not appropriate, please dont down vote.Just let me know. Thanks
It's perfectly appropriate. Your listener is created when the app starts, so it should be destroyed when the app exits.
Technically speaking, it's not really needed though. When your application exits, everything will be destroyed, including the listener.
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