开发者

Making a table's display dependent on the selection in another table in Interface Builder

I've got a window set up with two NSTableViews. In Core Data I have two entities set up, one of them containing members of the other, larger grouping (e.g. cars and manufacturers). I've got entry pages set up f开发者_如何学编程or each entity and they play nicely there (no faulting when trying to select from a many-to-one in a drop menu). What I'm trying to do now is take that one step further so that when I select a manufacturer in the main NSTableView, the list of cars related to that manufacuturer will appear in the second NSTableView.

I've tried using bindings similar to what I've done for the manufacturer popup button, feeding the value from the cars entity, however it's simply showing a list of all the car entries, regardless of which manufacturer I select. I don't see any options for a predicate to filter it, however, and if I set the binding's key path to manufacturer.cars, it shows a relationship fault. How can I filter what gets displayed in the child table?


Have two NSArrayControllers. Bind the contentArray of the cars controller to the manufacturers controller; the controller key is selection (i.e., the selected manufacturer), and the model key path is that of the property containing the manufacturer's cars.

Then, bind the cars table view's columns to properties of the cars controller's arrangedObjects.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜