Re: NSArrayController/Modal dialog/KVO Gordian knot
Re: NSArrayController/Modal dialog/KVO Gordian knot
- Subject: Re: NSArrayController/Modal dialog/KVO Gordian knot
- From: Keary Suska <email@hidden>
- Date: Sat, 12 Jun 2010 08:10:30 -0600
On Jun 12, 2010, at 2:55 AM, vincent habchi wrote:
> Hi again,
>
> I am still stuck in my (very simple) dialog management. Briefly, I have a modal dialog that allows the user to create objects whose attributes are derived from various fields. I need to set the a default value to one attribute of a newly created object (after clicking on a button); however this scheme:
>
> [arrayController insert]
> [arrayController setSelectionIndex:0]
> [[arrayController selection] setValue:foo forKey:@"spam"]
>
> fails, because the creation of the new object is postponed until next Runloop iteration (so when the arrayController is void, there is no selection). I tried KVO on the "content" key of arrayController, but it fails also, the observation message seems to be hold until the modal runloop exits.
>
> Any possible alternative?
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.
HTH,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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