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: Brad Gibbs <email@hidden>
- Date: Fri, 14 Nov 2008 15:21:51 -0800
Thanks for the thoughts, Quincey, but I couldn't make that work.
I have a categoriesAC which is bound to File's Owner's MOC and set to
Entity mode for Category.
My categories Popup Button (categoriesPUB) is bound to the categories
array controller as follows:
Content.arrangedObjects
ContentValues.arrangedObjects.displayName
I've tried a variety of bindings for the popup button's selectedObject
binding, but I'm not sure how to bind it in this instance.
I tried binding the typesAC's contentSet to File's
Owner.categoriesPUB.selectedItem.representedObject.children
but nothing showed up in the typesPUB.
Re: Core Data, Filtering by PopUps & Bindings Confusion
FROM : Quincey Morris
DATE : Fri Nov 14 22:31:26 2008
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