On Mar 25, 2010, at 15:39, Joanna Carter wrote:

> But, this dictionary method does mean populating the dictionary before 
> editing and then shoving it into the object controller, then doing the 
> reverse after editing.

Well, this statement confuses me.

The dictionary only has to be populated ahead of time if you want specific 
values to be pre-filled for editing, but that's a side issue.

Do you mean the dictionary has to be "shoved" into the object controller 
because the dictionary is being created separately from nib instantiation so 
the object controller doesn't otherwise know about it*?

I'm flummoxed by "doing the reverse". What is that? Aren't the results of 
editing already in the dictionary as the values of the key? What's left to 
actually *do* that involves the object controller?


* Again, I'd be likely to follow a different approach, to avoid having to write 
"hook it up" glue to do the shoving, such as:

1. Put the dictionary in the nib file and connect it to the object controller's 
content outlet. (I probably still wouldn't ask the object controller for its 
content, though. I think I'd add an outlet from File's Owner directly to the 
dictionary.)

2. Have File's Owner (which I am thinking of as a window controller for the 
sheet that's gathering the new object information) make the dictionary 
available as a property, and bind the object controller to that.

3. [what I actually do] Avoid using a dictionary on the user interface side, 
but implement the various object attributes as fully-feldged properties (of the 
window controller, in the simplest case) that are bound from the UI elements 
via the object controller (whose purpose is *solely* to ensure that editing 
changes are committed properly). When OK is pressed that point (again in the 
simplest case), the window controller can create the real new object with the 
correct attributes.

The reason I avoid binding user interface elements to dictionary keys is that 
NSDictionary's KVC compliance is a bit hackish (and NSMutableDictionary's KVO 
compliance is mostly non-existent). As soon as you try to do anything 
complicated, the limitations start to become apparent. (That's usually the 
point at which people post to the list asking why "it doesn't work right".) 
Dictionary keys just aren't quite the same thing as KVC properties.


_______________________________________________

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

Reply via email to