Binding search field and table view in cocoa

穿精又带淫゛_ 提交于 2020-02-27 22:57:46

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/14562633/binding-search-field-and-table-view-in-cocoa

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!