Re: Core Data, Filtering by PopUps & Bindings Confusion
Re: Core Data, Filtering by PopUps & Bindings Confusion
- Subject: Re: Core Data, Filtering by PopUps & Bindings Confusion
- From: Quincey Morris <email@hidden>
- Date: Fri, 14 Nov 2008 13:31:26 -0800
On Nov 14, 2008, at 12:06, Brad Gibbs wrote:
I've been using Jonathan Dann's excellent Core Data Sorted sample
code to create an outline view consisting of two concrete entities
-- Categories and Types (each parent Category can have an unlimited
number of children types). The only real adjustment I've made to
his code is to put the parent relationship in the Category entity
and the children relationship in the Type entity. I've also
modified the indexPath of the addGroup method so that categories are
always root objects.
The outline view seems to be working fine. I'm using the addGroup
method to add categories and addLeaf to add types. This outline
view is in a preferences window in my app.
This section of the app is meant to be a product library. Users
will be able to sort and search by category or type. When adding a
new product, a type is assigned to the product, using the selected
value of a popup button. I'd like to limit the number of types in
that popup button by using a category popup button. In other words:
1. User indicated s/he wants to add a new product
2. User selects a category from a popbutton menu
3. App loads the selected category's types in the the types popup
button
4. User selects a type and the type is assigned to the type
relationship for the product being created or edited.
I've got two array controllers in my nib file -- one for categories
and another for types. I've tried just about every combination of
bindings I can imagine, but I can't get the types popup button to
limit itself to the types associated with the selected category --
at best it either displays all types of every category or it
populates the types popup menu for a selected category but doesn't
update itself when a different category is selected.
Should I be using a fetch request or a filter predicate instead? If
bindings is the right approach, could someone describe the bindings
that need to be made?
I haven't tried this, but if I understand the setup, the current
Category would be available from the popup button as
button.selectedItem.representedObject, assuming the button was bound
to a Categories NSArrayController which itself was bound to the
categories.
Therefore, your Types array controller would be need to be bound to
button.selectedItem.representedObject.types, and the only way I know
to do that is to add the button as an outlet on the file's owner, so
the actual binding is to File's
Owner.button.selectedItem.representedObject.types (or if there's a
more direct way, I'd be interested to know what it is).
HTH
_______________________________________________
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