我展示了一张带有NSTableView
(一栏),一个NSSearchField
and an NSButton
('添加')。
我想要的是将表视图的内容设置为字符串列表。该字符串列表位于NSArray
called list。应根据搜索字段的内容过滤此内容(如果list)不包含搜索字段的内容,它不再显示在表格视图中。
我对绑定不太熟悉,谁能帮帮我。
我已经上传了一个project http://www.keepandshare.com/doc/5393575/array-controller-search-59k?da=y, 好心检查。
大致的想法是:(但是通过查看项目更容易理解)
创建一个数组控制器。
-
设置为阵列控制器对象
Mode:Class
Class Name: Your custom Class
-
收到的行动
add: to the button that will add new objects, typically labelled with +
remove:to the button that will add new objects., typically labelled with -
引用绑定(从表或从此处针对表的每一列)。
-
对于搜索字段
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…. )
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)