Re: calling a function in one class from another
Re: calling a function in one class from another
- Subject: Re: calling a function in one class from another
- From: Geoffrey Holden <email@hidden>
- Date: Tue, 10 Aug 2010 10:06:24 +0100
I'm writing an app which communicates with a server. The protocol that it
uses is subject to change, so I'm writing a plugin to support that
particular protocol. When, in the future, the protocol changes (as it
probably will), I'll only need to change the plugin and not the entire app.
That's my thinking anyway.
Sometimes, the server will send an update message out - my plugin can
respond to these events correctly, but (obviously) I need my app to - so,
effectively, I need to find a way of delegating the response to the app (the
plugin needs to pass the event on).
At the moment, my plugin protocol looks like this - obviously, it doesn't
support events at this stage and I need to update it accordingly. At this
stage, the app and its plugin can make a connection to the remote server
but, without being able to respond to updates from the server, it's all a
bit useless.
@protocol ConnectionPluginProtocol
+ (BOOL)activate;
+ (void)deactivate;
- (void) doLogin;
- (void) doLogout;
- (void) doStartConnection:(NSString*)destination:(NSString*)body;
@end;
Thanks for all your help.
On Tue, Aug 10, 2010 at 3:28 AM, Graham Cox <email@hidden> wrote:
>
> On 10/08/2010, at 7:13 AM, Geoffrey Holden wrote:
>
> > On a related note, how does this relate to plugin bundles? I've created
> a plugin (using the tutorial in Aaron Hillegass's excellent book) - and it
> works perfectly. I want to be able to respond to events in the plugin
> though - would IBAction be the best way to do this since there doesn't seem
> to be a way of getting the App to be a delegate for one of its plugins?
>
>
> What do you mean by 'events'? Actual events, such as mouse down, key
> strokes, that sort of thing? Or do you really mean 'actions', which are
> responders to button clicks, menu choices, etc.
>
> IBActions are useful for the latter. Events are a lower level concept (for
> example, a mouse down, mouse drag and mouse up could be a whole series of
> events that a button responds to, but which trigger one action, which
> informs the button's controller that the button was "clicked"). Actions are
> typically used to connect a user interface item to a controller that gives
> that user interface item some functional meaning by manipulating the data
> model appropriately.
>
> A plug-in is not restricted as to what sort of UI it can present. You
> typically don't want the app (or its delegate) to be a controller on behalf
> of a plug-in's UI. It's not actually impossible but it's a crazy design, so
> I'm glad you think it is impossible! A plug-in can have a nib or nibs that
> provide a user interface just as the app can. How the plug-in interfaces to
> the app itself is up to you, but this should be happening at the controller
> or data-model level, not the UI. Other than that there's not much advice to
> give, given that I don't know anything about what your app or its plugins
> do.
>
> --Graham
>
>
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden