• 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
Using bindings to make an NSPopupButton to assign an array filter predicate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using bindings to make an NSPopupButton to assign an array filter predicate


  • Subject: Using bindings to make an NSPopupButton to assign an array filter predicate
  • From: James Farwell <email@hidden>
  • Date: Sun, 17 Dec 2006 16:34:25 -0800

Greetings,

I am attempting to use Cocoa Bindings in an app for the first time and I'm running into a bit of a roadblock. I have a list of data that can be filtered a few different ways, and I would like to let the user select how it is filtered via an NSPopupButton in my preferences window. I have an NSArrayController (dataController) managing the list of data, and another NSArrayController (predicateController) managing an list of predicates that define the different ways to filter. I am trying to figure out how to set up the Cocoa Bindings in such a way that selecting a different item in the NSPopupButton will cause the dataController to immediately apply the new predicate as its filter. Here is what I have so far:


predicateController (NSArrayController) ----- contentArray Bind to: controllerAlias Controller Key: selection Model Key Path: predicates -----


dataController (NSArrayController) ----- contentArray Bind to: controllerAlias Controller Key: selection Model Key Path: data ----- filterPredicate Bind to: predicateController Controller Key: selection.predicate -----


NSPopupButton ----- content Bind to: predicateController Controller Key: arrangedObjects ----- contenValues Bind to: predicateController Controller Key: arrangedObjects Model Key Path: name ----- selectedIndex Bind to: Shared User Defaults Controller Key: values Model Key Path: filter -----


When I build/run this, the NSPopupButton populates properly, and my data shows up filtered by the first predicate in the list, regardless of which is selected. If I try to change the selection of the NSPopupButton, the visible data does not change.


I can only assume that the NSPopupButton is not actually setting the "selection" of its content NSArrayController. My question is, does anyone know either how to get this scenario to work, or an example that does something very similar correctly.

Thanks a ton!
James
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


  • Follow-Ups:
    • Re: Using bindings to make an NSPopupButton to assign an array filter predicate
      • From: Keary Suska <email@hidden>
  • Prev by Date: Re: Objects not being added to array
  • Next by Date: Re: NSDocument subclass, File Wrappers & Core Data
  • Previous by thread: Re: NSMatrix, NSImageCell and selection indicator
  • Next by thread: Re: Using bindings to make an NSPopupButton to assign an array filter predicate
  • Index(es):
    • Date
    • Thread