Re: Creating an ordered list for combo-box content from a Core Data entity attribute
Re: Creating an ordered list for combo-box content from a Core Data entity attribute
- Subject: Re: Creating an ordered list for combo-box content from a Core Data entity attribute
- From: "I. Savant" <email@hidden>
- Date: Wed, 8 Apr 2009 18:45:54 -0400
On Apr 8, 2009, at 6:24 PM, Jon C. Munson II wrote:
However, your previous reply sparked something and I got the array
controller partially working. It now returns the list, albeit
unordered.
The contentArray (can't use contentSet in this case) is bound to the
"master" array controller's
email@hiddengAttribute. This gets
me the
aggregated list of stringAttributes (or so I think anyway).
Now, when I attempt to set the sort descriptor in the array
controller, I
get a not key-value coding compliant error. This is because there
is only
one attribute being returned and it apparently doesn't have a key
that I
know (and yes, I checked to make sure I spelled my keyPath
correctly). When
binding the combo-box content/content values, I simply used
arrangedObjects
with no keypath and that seems to be correct as the list is loaded and
displayed.
Okay, this is where we run into the same old problem of "not enough
info" to make a clear and concise answer. It's exceedingly difficult
to model all this without a clear description of what relevant (array)
controllers (by name) you're using, and how your popup is bound to its
source array controller, and how you're setting your sort descriptors.
In a simple test case, if you have an array controller which
controls a set of "Person" instances (from wherever), and Person has
the attribute "fullName, which you want to be both the displayed
string in the popup button, *and* the attribute by which they're
sorted, you need to:
1 - Set the array controller's sort descriptors (an array of
descriptors) to include a descriptor for the key "fullName".
2 - Bind the popup's *content* to the array controller's
arrangedObjects (no model key path).
3 - Bind the popup's *content values* to the array controller's
arrangedObjects, model key path "fullName".
4 - Bind the popup's *selected object* to the array controller's
selection (no model key path).
The reason we're distinguishing selected objects from their display
values is that, being a Core Data application as you mentioned, it's
likely that the "Person" (or whatever it is for you) selected with the
popup will set some relationship for some other object. You need the
object, rather than the name in this case.
--
I.S.
_______________________________________________
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