Re: NSArrayController/Modal dialog/KVO Gordian knot
Re: NSArrayController/Modal dialog/KVO Gordian knot
- Subject: Re: NSArrayController/Modal dialog/KVO Gordian knot
- From: vincent habchi <email@hidden>
- Date: Sat, 12 Jun 2010 17:30:39 +0200
Le 12 juin 2010 à 16:10, Keary Suska a écrit :
> Normally, default value logic should be within the model object, not the controller. If the defaults are specific to the controller or situation (and not to any other controller or situation), the controller should be told to prepare its own content and set default values accordingly. Along with setting "selects inserted objects", I consider one of these to be your best alternative.
Well, I think the default value is within the model object. To make it clearer, suppose I have a model object (entity in Core data) that could represent fruits (in general) and has a "color" attribute. I have a PopUp that allows the user to select exactly what fruit he wants to create (apple, cherry, lemon…) and when it clicks on the "new" button (or changes his mind after), the "color" attribute of the newly created object is set accordingly.
The mechanism I use is this: I register key/value pairs in a dictionary (@"apple"/apple_object, @"cherry"/cherry_object…), controlled by a NSDictionaryController; The keys are displayed as PopUp value items, and each fruit object abides by a protocol featuring a + (NSString)color method that returns the appropriate color. The color field should be set to : theDictionary.selection.value.color; but I can't get a valid "selection" proxy object. I tried to use a non-modal window, but to no avail. There seems to be an interference with core data.
Vincent_______________________________________________
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