Bindings between different controllers question...
Bindings between different controllers question...
- Subject: Bindings between different controllers question...
- From: Aurélien Hugelé <email@hidden>
- Date: Wed, 25 May 2005 15:36:22 +0200
Hi list !
Before attending to WWDC 2005, i'm trying to improve my "cocoa
binding" knowledge... and i'm facing a problem i can't solve :-(
can anyone help ?
imagine my software as a simple, plugin based, phone dialing
software : only 2 controllers, both as singleton.
"PhoneController", is the main controller, it loads the plugin
(Bluetooth mobile phone, Internal Modem, Speakers, and maybe another
specific one) that are able to dial a phone number using the device
they are made for. The loaded plugins are stored in an NSArray, and
only one of them can be active at any instant, it is called
activePlugin and store in an attribute.
This controller has 3 basic accessors :
-(NSArray*) plugins; // returns a list of the loaded plugins
-(Plugin*)activePlugin; // return the currently activePlugin
-(void)setActivePlugin:(Plugin*)aPlugin; // to modify the activePlugin
/*
// convenience methods to see if cocoa bindings are easier to manage
with indexes instead of object...
-(unsigned int)activePluginIndex;
-(void)setActivePluginIndex:(unsigned int)index;
*/
OutgoingCallController is another singleton controller, it manages
the dialing panel where you can choose the person to call and the
plugin you want to use to dial.
Then the binding...
OutgoingCallController has a nib for the UI of the dial panel, with a
pop up button to choose the plugin.
I've added a NSArrayController to this nib to access the list of
plugins (the OutgoingCallController has a pointer to the
PhoneController).
The NSArrayController is bound to the OutgoingCallController (the
file's owner) and the model key path is set to
"phoneController.plugins" so that the NSArrayController access the
array of plugins by traversing the file owner->phoneController->plugins.
My Pop up is correctly filled at startup by the NSArrayController and
i can see all my plugins.
But what i want to do is to have the currently "activePlugin" (there
can be only one) synchronized with the NSArrayController and the UI :
Currently, when i choose another plugin in the pop up, the
"selectionIndex" of the NSArrayController is changed, but how can i
make "setActivePlugin:" called on PhoneController, so that
NSArrayController selection/selectedObject/selectedIndex matches the
activePlugin ?
Of course, with a simple action on the pop up i can do something like
[phoneController setActivePlugin:XXXX]; and that works, but i want
the other way too !! i want that ANY call to [phoneController
setActivePlugin:] change the NSArrayController selection ! So if
later, i PROGRAMMATICALY call [phoneController
setActivePlugin:myPlugin], the NSArrayController selection change,
and the Pop Up button is modified ??
is n't this one of the this possible with cocoa bindings ?
As a summary, i want that a call to setActivePlugin: change the
selection of an NSArrayController... how is it possible ?
Thanks for your time :)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden