You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2013/02/20 20:15:39 UTC
ios commit: [CB-1547] Scope notifications to WebViews
Updated Branches:
refs/heads/master 1bfff2d16 -> 709d60786
[CB-1547] Scope notifications to WebViews
Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/709d6078
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/709d6078
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/709d6078
Branch: refs/heads/master
Commit: 709d6078693956e7514c8f21d8b8b77f72edcd6b
Parents: 1bfff2d
Author: Andrew Grieve <ag...@chromium.org>
Authored: Wed Feb 20 14:15:01 2013 -0500
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Wed Feb 20 14:15:01 2013 -0500
----------------------------------------------------------------------
CordovaLib/Classes/CDVPlugin.h | 8 ++++----
CordovaLib/Classes/CDVPlugin.m | 9 +++++++--
CordovaLib/Classes/CDVSplashScreen.m | 2 +-
CordovaLib/Classes/CDVViewController.m | 11 +++--------
4 files changed, 15 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/709d6078/CordovaLib/Classes/CDVPlugin.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPlugin.h b/CordovaLib/Classes/CDVPlugin.h
index f5b50eb..6e25a27 100644
--- a/CordovaLib/Classes/CDVPlugin.h
+++ b/CordovaLib/Classes/CDVPlugin.h
@@ -23,10 +23,10 @@
#import "NSMutableArray+QueueAdditions.h"
#import "CDVCommandDelegate.h"
-#define CDVPageDidLoadNotification @"CDVPageDidLoadNotification"
-#define CDVPluginHandleOpenURLNotification @"CDVPluginHandleOpenURLNotification"
-#define CDVPluginResetNotification @"CDVPluginResetNotification"
-#define CDVLocalNotification @"CDVLocalNotification"
+NSString* const CDVPageDidLoadNotification;
+NSString* const CDVPluginHandleOpenURLNotification;
+NSString* const CDVPluginResetNotification;
+NSString* const CDVLocalNotification;
@interface CDVPlugin : NSObject {}
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/709d6078/CordovaLib/Classes/CDVPlugin.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPlugin.m b/CordovaLib/Classes/CDVPlugin.m
index a42d241..8c932a0 100644
--- a/CordovaLib/Classes/CDVPlugin.m
+++ b/CordovaLib/Classes/CDVPlugin.m
@@ -19,6 +19,11 @@
#import "CDVPlugin.h"
+NSString* const CDVPageDidLoadNotification = @"CDVPageDidLoadNotification";
+NSString* const CDVPluginHandleOpenURLNotification = @"CDVPluginHandleOpenURLNotification";
+NSString* const CDVPluginResetNotification = @"CDVPluginResetNotification";
+NSString* const CDVLocalNotification = @"CDVLocalNotification";
+
@interface CDVPlugin ()
@property (readwrite, assign) BOOL hasPendingOperation;
@@ -41,7 +46,7 @@
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppTerminate) name:UIApplicationWillTerminateNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleOpenURL:) name:CDVPluginHandleOpenURLNotification object:nil];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onReset) name:CDVPluginResetNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onReset) name:CDVPluginResetNotification object:theWebView];
self.webView = theWebView;
}
@@ -64,7 +69,7 @@
// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveLocalNotification:) name:CDVLocalNotification object:nil];
// Added in 2.5.0
- // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pageDidLoad:) name:CDVPageDidLoadNotification object:nil];
+ // [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pageDidLoad:) name:CDVPageDidLoadNotification object:self.webView];
}
- (void)dispose
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/709d6078/CordovaLib/Classes/CDVSplashScreen.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVSplashScreen.m b/CordovaLib/Classes/CDVSplashScreen.m
index 7561609..949444e 100644
--- a/CordovaLib/Classes/CDVSplashScreen.m
+++ b/CordovaLib/Classes/CDVSplashScreen.m
@@ -28,7 +28,7 @@
- (void)pluginInitialize
{
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pageDidLoad) name:CDVPageDidLoadNotification object:nil];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(pageDidLoad) name:CDVPageDidLoadNotification object:self.webView];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onOrientationWillChange:) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
if (self.useSplashScreen) {
http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/709d6078/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index d625424..9bf6990 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -540,7 +540,7 @@
[self processOpenUrl];
- [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPageDidLoadNotification object:nil]];
+ [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPageDidLoadNotification object:self.webView]];
}
- (void)webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
@@ -823,13 +823,8 @@
- (void)dealloc
{
[CDVURLProtocol unregisterViewController:self];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillTerminateNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillResignActiveNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:NSCurrentLocaleDidChangeNotification object:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:CDVPluginHandleOpenURLNotification object:nil];
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+
self.webView.delegate = nil;
self.webView = nil;
[CDVUserAgentUtil releaseLock:&_userAgentLockToken];