Updated Branches: refs/heads/master 4a3b22064 -> 99b424fb1
Fixes CB-1578 remove notification observers Updated CDVPlugin.m to remove all handlers via [NSNotificationCenter removeObserver:self] rather than removing all notifications individually. Updated CDVConnection.m and CDVLocalStorage.m with the same call in dealloc method because they individually add notifications. That isn't absolutely necessary since notification will now be removed in base class. Verified that it is ok to call removeObserver more than once. Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/99b424fb Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/99b424fb Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/99b424fb Branch: refs/heads/master Commit: 99b424fb17e9c4623d410fac3fdd6cb31dee5dfe Parents: 4a3b220 Author: Becky Gibson <becka...@apache.org> Authored: Thu Oct 4 17:35:59 2012 -0400 Committer: Becky Gibson <becka...@apache.org> Committed: Mon Oct 8 13:35:09 2012 -0400 ---------------------------------------------------------------------- CordovaLib/Classes/CDVConnection.m | 1 + CordovaLib/Classes/CDVLocalStorage.m | 5 +++++ CordovaLib/Classes/CDVPlugin.m | 15 +++------------ 3 files changed, 9 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/99b424fb/CordovaLib/Classes/CDVConnection.m ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVConnection.m b/CordovaLib/Classes/CDVConnection.m index 0223a3a..3eef1d5 100644 --- a/CordovaLib/Classes/CDVConnection.m +++ b/CordovaLib/Classes/CDVConnection.m @@ -144,6 +144,7 @@ - (void)dealloc { [self onReset]; + [[NSNotificationCenter defaultCenter] removeObserver:self]; // this will remove all notifications unless added using addObserverForName:object:queue:usingBlock: } - (void)onReset http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/99b424fb/CordovaLib/Classes/CDVLocalStorage.m ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVLocalStorage.m b/CordovaLib/Classes/CDVLocalStorage.m index 8f87be0..6486a4e 100644 --- a/CordovaLib/Classes/CDVLocalStorage.m +++ b/CordovaLib/Classes/CDVLocalStorage.m @@ -410,6 +410,11 @@ #pragma mark - #pragma mark Over-rides +- (void)dealloc +{ + [[NSNotificationCenter defaultCenter] removeObserver:self]; // this will remove all notification unless added using addObserverForName:object:queue:usingBlock: +} + @end #pragma mark - http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/99b424fb/CordovaLib/Classes/CDVPlugin.m ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVPlugin.m b/CordovaLib/Classes/CDVPlugin.m index 022d1fe..9d83f27 100644 --- a/CordovaLib/Classes/CDVPlugin.m +++ b/CordovaLib/Classes/CDVPlugin.m @@ -53,7 +53,8 @@ // http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006728-CH3-DontLinkElementID_4 /* - // NOTE: if you want to use these, make sure you uncomment the corresponding notification handler, and also the removeObserver in dealloc + // NOTE: if you want to use these, make sure you uncomment the corresponding notification handler + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPause) name:UIApplicationDidEnterBackgroundNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume) name:UIApplicationWillEnterForegroundNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onOrientationWillChange) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil]; @@ -109,17 +110,7 @@ - (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillTerminateNotification object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:CDVPluginHandleOpenURLNotification object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:CDVPluginResetNotification object:nil]; - - /* - [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillChangeStatusBarOrientationNotification object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; - */ + [[NSNotificationCenter defaultCenter] removeObserver:self]; // this will remove all notification unless added using addObserverForName:object:queue:usingBlock: } - (id)appDelegate