Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.