I have a typical Mac CoreData application which displays my entities in an NSTableView
with an NSArrayController
, and a panel on the right to edit/display the currently selected item in the NSTableView
. I have an Entity
(Pigeon) with an NSString
property (colour) being displayed in an NSComboBox
, so that the user can enter their own string for the colour or select a previously chosen colour from the drop down list. This is done by binding the Content Values of the NSComboBox
to Pigeons.arrangedObjects.colour
. This is sooooooo close to what I want, but because it's an array (and not a set) of all the colours that exist for the pigeons, duplicate values are listed in the drop down list of the NSComboBox
. So if for example Blue is entered for the colour for one Pigeon, and it's also selected for a second Pigeon, then Blue is shown in the list twice.
Is there someway, somehow I can filter this to remove duplicate values? I've tried making a second NSArrayController
which is bound to the Pigeons.arrangedObjects.colour
and setting an NSPredicate
to filter it, but I can't seem to figure out an NSPredicate
for filtering out duplicate values. I want to use bindings for the values of the colours, so that as the application is running, if a colour is added or deleted (maybe a mistake was made in entering a colour), then the drop down list is updated to only have the currently entered colour values for Pigeons.
What is the best way to not showing these duplicate values?
I am on my phone and a little lazy, but I think you are looking for a keypath that looks like: @"@distinctunionofobects.someproperty"... Or google keypath operators.