Я пытаюсь создать простой интерфейс к своей базовой модели данных в стиле браузера Жанра iTunes.
У меня есть образцовая установка с тремя объектами: Genre <-->> Artist <-->> Album
.
Я хотел бы просто связать их каждый с NSTableView, но появляется, как будто доступ к дочерним отношениям от NSArrayController не KVC совместимый. Так, я испытываю затруднения при передаче выбранных объектов Жанра к ArtistController.
Как дела это? Это даже возможно в IB без какого-либо пользовательского разделения на подклассы?
Редактирование для Потомства: Я делал несколько вещей неправильно.
Entity
Режим, а скорее действуют в качестве a NSMutableDictionary
класс.Content Set
привязка. Используйте ключ контроллера selection
, и образцовый ключевой путь, который соединяется с детьми.уф. И ответ Brian и это учебное руководство MacResearch были полезны в определении моих ошибок (и какие первые части имели право).
The approach I would probably take is to have a separate NSArrayController for each table view, then have the content of one array controller be based on the selection of another.
For example, say you have table view A that displays the list of available genres, so it has an array controller A whose content is hooked up to your managed object context.
Then, say you have table view B which shows the available artists for whichever genre is selected in table A. This table would have its own array controller B, and the content array for controller B is bound so the "controller key" field in IB is set to the "selection" key of controller A, with "artists" being the model key (this assumes your Genre entity has a to-many relationship named "artists" to the Artist entity).
You can then apply the same principle to a third table view + controller to show the albums for the selected artist.
The general term for this kind of setup is a "master-detail interface", and is outlined in Apple's docs at this link