Pregunta

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.

¿Fue útil?

Solución

I have uploaded a project, kindly check.

A rough idea how to do is as: (however understanding is easier by seeing the project)

  1. Create an Array Controller.

  2. Set for Array controller Object

      Mode:Class
    
      Class Name: Your custom Class
    
  3. 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 -
    
  4. Referencing Bindings(either from table or from here for each column of table).

  5. 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…. )
    
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top