cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Shazron <shaz...@gmail.com>
Subject Re: CDVPlugins and Designated Initializers
Date Thu, 14 Feb 2013 19:29:59 GMT
I doubt any plugins use the initWithWebView:settings: selector at all,
might be legacy stuff in there that needs to be weeded out.
Let's deprecate them and use two-phase initialization. pluginDidInitialize
to me implies a notification-like method, how about pluginInitialize


On Thu, Feb 14, 2013 at 10:09 AM, Andrew Grieve <agrieve@chromium.org>wrote:

> The iOS plugin guide doesn't mention init methods for plugins. We should
> fix this...
>
> But first, how...
>
> Right now we have:
>
> - (CDVPlugin*)initWithWebView:(UIWebView*)theWebView
> > settings:(NSDictionary*)classSettings
> > {
> >     self = [self initWithWebView:theWebView];
> >     if (self) {
> >         self.settings = classSettings;
> >         self.hasPendingOperation = NO;
> >     }
> >     return self;
> > }
> > - (CDVPlugin*)initWithWebView:(UIWebView*)theWebView
> > {
> >     self = [super init];
> >     ...
>
>
> So... Looks like initWithWebView: is the designated initializer, but the
> plugin doesn't get it's settings set until after it returns. Also,
> self.viewController and self.commandDelegate get set after the initializer
> altogether.
>
> In Android, we use two-step initialization:
>
>                 this.plugin = (CordovaPlugin) c.newInstance();
> >                 this.plugin.initialize(ctx, webView);
>
> We can't remove either initializer without breaking compatibility, but
> maybe we could deprecate them?
>
> I think it also makes sense to use two-phase initialization on iOS. Perhaps
> "pluginDidInitialize".
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message