• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Core Data, Filtering by PopUps & Bindings Confusion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Core Data, Filtering by PopUps & Bindings Confusion (From: Brad Gibbs <email@hidden>)

  • Prev by Date: Re: Distributed Objects Performance
  • Next by Date: RE: How do you get the OS X version number in C or C++?
  • Previous by thread: Core Data, Filtering by PopUps & Bindings Confusion
  • Next by thread: Re: Core Data, Filtering by PopUps & Bindings Confusion
  • Index(es):
    • Date
    • Thread