I present a sheet with an NSTableView
(one column), an NSSearchField
and an NSButton
('Add').
What I want is to set the content of the table view to a list of strings. This list of strings is in an NSArray
called list. This content should be filtered based on the content of the search field (if a string in list) does not contain the content of the search field it is not shown in the table view anymore.
I'm not familiar with bindings, can anyone help me out.
I have uploaded a project, kindly check.
A rough idea how to do is as: (however understanding is easier by seeing the project)
Create an Array Controller.
Set for Array controller Object
Mode:Class Class Name: Your custom Class
Received Actions
add: to the button that will add new objects, typically labelled with + remove:to the button that will add new objects., typically labelled with -
Referencing Bindings(either from table or from here for each column of table).
For search field
Bindings, Predicate to Array Controller ControllerKey : filterPredicate Predicate Format : <class property> contains $value (if to search in multiple table columns then <class property 1> contains $value || <class property 2> contains $value etc…. )
来源:https://stackoverflow.com/questions/14121152/filtering-a-single-column-nstableview-using-nsarraycontroller