Search code examples
cocoabindingnsarraycontroller

want to filter out Windows admin shares from my arrangedObjects NSArrayController


I have everything set up in my NSArrayController to have my files owner representedObject be the data source for a tableview that I have.

Within my bindings in interface builder I would like to use the filter predicate to filter out any items in the arraycontroller that have a $ in the name.... specifically ending in $ actually as this is how windows admin shares look like when I get the array of FTP shares I am collecting.

I have set up the filter predicate as so: controller key: selection modelKeyPath : directorsAndFiles

value Transformer: hmm I dont know? can you help

wanted: eliminate any items that have $ characters in them

thanks!


Solution

  • First of all, you don't need a value transformer in this case. A value transformer changes the display of a value. For example, it may cause the number 2 to be displayed as "€ 2,00" -- or whatever you may like.

    Second, the predicate syntax you're looking for is "ENDSWITH" as in :

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name not ENDSWITH '$'"];