user1999892
user1999892

Reputation: 135

Binding search field and table view in cocoa

I have a nstableview. I would like to filter the results based on the characters entered in a search bar in OSX. So how do i bind the table view and the search field in OSX not in IOS? :) Thanks.

Upvotes: 6

Views: 2800

Answers (1)

Anoop Vaidya
Anoop Vaidya

Reputation: 46543

I have a project that you can download and look how it works.

The steps are as :

  1. Drag NSArrayController, set all bindings with this. Create NSSearchField.

  2. In binding inspector, Search "Bind to ArrayController".

  3. Set Controller Key to "filterPredicate".

  4. Set Predicate Format to "property1 contains $value" If you want a single search field to search on multiple values(say 3) use || as : "property1 contains $value || property2 contains $value || property3 contains $value"

Also, this StackOverFlow Question.

Upvotes: 6

Related Questions