Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 75D78DE82 for ; Mon, 8 Oct 2012 17:44:46 +0000 (UTC) Received: (qmail 1883 invoked by uid 500); 8 Oct 2012 17:44:46 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 1849 invoked by uid 500); 8 Oct 2012 17:44:46 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 1841 invoked by uid 99); 8 Oct 2012 17:44:46 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Oct 2012 17:44:46 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 254E73C4D1; Mon, 8 Oct 2012 17:44:46 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: becka11y@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: ios commit: Fixes CB-1578 remove notification observers Message-Id: <20121008174446.254E73C4D1@tyr.zones.apache.org> Date: Mon, 8 Oct 2012 17:44:46 +0000 (UTC) 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 Authored: Thu Oct 4 17:35:59 2012 -0400 Committer: Becky Gibson 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