gpt4 book ai didi

macos - 使用 NSArrayController 过滤单列 NSTableView

转载 作者:行者123 更新时间:2023-12-03 16:17:56 25 4
gpt4 key购买 nike

我展示了一张包含 NSTableView(一列)、NSSearchFieldNSButton(“添加”)的工作表。我想要的是将 TableView 的内容设置为字符串列表。此字符串列表位于名为 listNSArray 中。应根据搜索字段的内容过滤此内容(如果列表中的字符串)不包含搜索字段的内容,则不再显示在表格 View 中。

我对绑定(bind)不熟悉,谁能帮我。

最佳答案

我上传了project ,请检查。

大致的做法是:(但是通过查看项目更容易理解)

  1. 创建数组 Controller 。

  2. 设置为数组 Controller 对象

      Mode:Class

    Class Name: Your custom Class
  3. 收到的操作

      add: to the button that will add new objects, typically labelled with +

    remove:to the button that will add new objects., typically labelled with -
  4. 引用绑定(bind)(从表中或从此处针对表的每一列)。

  5. 搜索字段

     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…. )

关于macos - 使用 NSArrayController 过滤单列 NSTableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14121152/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com