Binding NSArrayController to NSSearchField and viewing result in NSTableView
Asked Answered
S

2

5

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.

Sparge answered 22/11, 2013 at 11:59 Comment(0)
H
11
  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
Halfmoon answered 22/11, 2013 at 12:29 Comment(2)
Michael, I tried a Predicate Format like self.name contains[cd] $value OR self.title contains[cd] $value but it doesn't work. Do you know how to combine to predicate?Idiosyncrasy
Auto-answer: put parenthesis. (self.name contains[cd] $value) OR (self.title contains[cd] $value) works.Idiosyncrasy
I
1

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)
Idiosyncrasy answered 1/6, 2016 at 14:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.