On Jan 19, 2009, at 9:58 PM, Brad Gibbs wrote:

I have a Core Data app with a container view controller and multiple subviews, each with a view controller and a separate NIB. Subview switching is done via a segmented control. The subviews each display the same data, but in different ways -- one is a table view, another is an image view and the third is a cover flow view.

The container view displays the segmented control that does the switching and a search field that is used to filter what is shown in the subviews. My aim is to have the search field filter the three views equally, such that if the user performs a search, all three subviews will show the filtered results of that search. So, the user the perform the search and each of the three views will display the filtered results of the same search.

I've tried a number of approaches. To me, it seems the most logical approach is to have the container view pass its MOC and NSArrayController instance to each of the subviews as it creates them. I still need to create an NSArrayController instance in each view's NIB file in IB to bind the objects in each of the views, but I can create an outlet in each view controller and set it to the NSArrayController instance passed in from the main view when the subview is instantiated. But, this doesn't seem to work. I can NSLog each array controller to see that each view has the same instance of the NSArrayController, but searching in the main view doesn't seem to filter any of the subviews properly.

If I understand this correctly, you have an NSArrayController instantiated in the nib, and one created programmatically. If they aren't connected in some way, there is no way for the "filtered" NSArrayController to communicate its changed contents to the nib-based controller, so the display never changes.

One better solution, I think, is to not use bindings at all for the search field. Instead, connect it to the main controller (target/ action is probably best), who on execution sets a filter predicate that is a property bound from the NSArrayController in the nib. Or, if you already have outlets to the NSArrayController, you can just call - setFilterPredicate:.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to