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 (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com