You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2013/03/20 20:39:02 UTC

ios commit: [CB-2699] Bug in dynamic loading of a plugin at CDVViewController's registerPlugin method

Updated Branches:
  refs/heads/master 8e31e9f9a -> 66caa6a21


[CB-2699] Bug in dynamic loading of a plugin at CDVViewController's registerPlugin method


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/66caa6a2
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/66caa6a2
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/66caa6a2

Branch: refs/heads/master
Commit: 66caa6a21a56ac2b1dc97d63ab1440301d7cfc9e
Parents: 8e31e9f
Author: Shazron Abdullah <sh...@apache.org>
Authored: Tue Mar 19 17:46:08 2013 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Wed Mar 20 12:38:51 2013 -0700

----------------------------------------------------------------------
 CordovaLib/Classes/CDVViewController.h |    1 +
 CordovaLib/Classes/CDVViewController.m |   16 ++++++++++++++++
 2 files changed, 17 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/66caa6a2/CordovaLib/Classes/CDVViewController.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.h b/CordovaLib/Classes/CDVViewController.h
index eef589a..2338baf 100644
--- a/CordovaLib/Classes/CDVViewController.h
+++ b/CordovaLib/Classes/CDVViewController.h
@@ -66,6 +66,7 @@
 
 - (id)getCommandInstance:(NSString*)pluginName;
 - (void)registerPlugin:(CDVPlugin*)plugin withClassName:(NSString*)className;
+- (void)registerPlugin:(CDVPlugin*)plugin withPluginName:(NSString*)pluginName;
 
 - (BOOL)URLisAllowed:(NSURL*)url;
 

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/66caa6a2/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m b/CordovaLib/Classes/CDVViewController.m
index 60b2997..142d0ae 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -743,6 +743,22 @@
     [plugin pluginInitialize];
 }
 
+- (void)registerPlugin:(CDVPlugin*)plugin withPluginName:(NSString*)pluginName
+{
+    if ([plugin respondsToSelector:@selector(setViewController:)]) {
+        [plugin setViewController:self];
+    }
+    
+    if ([plugin respondsToSelector:@selector(setCommandDelegate:)]) {
+        [plugin setCommandDelegate:_commandDelegate];
+    }
+    
+    NSString* className = NSStringFromClass([plugin class]);
+    [self.pluginObjects setObject:plugin forKey:className];
+    [self.pluginsMap setValue:className forKey:[pluginName lowercaseString]];
+    [plugin pluginInitialize];
+}
+
 /**
  Returns an instance of a CordovaCommand object, based on its name.  If one exists already, it is returned.
  */