Multiple Selection for NSArrayController and Cocoa Bindings
For the records:Say you have a master-detail pattern between Playlist and Song objects, both are shown in NSTableViews. Now if you select mutliple playlists, you want all the songs from all selected lists being merged together and displayed in the songs table.
Q: What bindings do I need for that? I tried a lot during the last hour and always got exceptions or an empty song table!
A: Bind the songs’ NSArrayController’s:
- “Managed Object Context” to your one Managed Object Context,
- “Content Set” to your playlists NSArrayController,
Controller Key:selectionand
Model Key Path:songsand - “Content Array for Multiple Selections” to your playlists NSArrayController,
Controller Key:selectionand
Model Key Path:@distinctUnionOfArrays.songs.
This solution is not really obvious, but if everything else is set up right, you should now get the desired merging-for-multiple-selection behavior.

