Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binding NSArrayController to NSSearchField and viewing result in NSTableView

My app description,

  1. Add NSMutableArray with some items (say 1- 50)
  2. Add NSArrayController and add/bind that array to this arrayController
  3. Add NSTableView to my view and populate them using the concept of BINDINGS.
  4. Finally add a NSSearchField and complete the app by adding/binding the NSArrayController with searchField.

I would like to know if this approach is how it is meant to be, I have searched but couldn't find a way of displaying populated arrays in a NSTableView using NSArrayController binds.

Help me through.

like image 413
Xander Avatar asked Dec 19 '22 21:12

Xander


2 Answers

If you wish to combine several predicates, follow Mikael steps and do:

  • Under Predicate Format write something like: (self.name contains[cd] $value) OR (self.title contains[cd] $value)
like image 27
Colas Avatar answered Feb 23 '23 07:02

Colas


  1. Bind your NSSearchField to the same NSArrayController you use for the NSTableView
  2. In bindings for your NSSearchField under Search and Predicate set the Controller Key to filterPredicate and Display Name to predicate
  3. Under Predicate Format write something like: self.name contains[cd] $value
like image 165
Mikael Avatar answered Feb 23 '23 05:02

Mikael