过滤出现在 NSPopUpButton 列表中的核心数据实体中的条目

发布于 2024-08-13 01:43:23 字数 870 浏览 4 评论 0原文

我熟悉如何将一个核心数据实体中的数据馈送到 NSPopUpButton 项中,以便可以为另一个项选择该数据。像这样的绑定:

对于值本身:

-> ValueSelection.Content
    Bind To: Value Source Entity
    Controller Key: arrangedObjects
    Model Key: N/A

对于 NSPopUpButton 中显示的值:

-> ValueSelection.ContentValues
    Bind to: Same entity as ValueSelection.Content
    Controller Key: arrangedObjects
    Model Key: the name of the attribute you wish to have displayed

将其链接到目标值:

-> ValueSelection.SelectedObject
    Bind to: Destination entity
    Controller Key: selection
    Model Key: Name of the attribute/relationship in the destination entity.

我想做的是弄清楚是否有办法设置一个过滤器(我猜是在 ContentValues 中),您只能让它从检查了特定属性标志的实体中获取条目(例如,假设我从我的 users 中提取条目) code> 实体,我只想列出男性或女性用户)。

I'm familiar with how to feed data from one Core Data entity into an NSPopUpButton item so that it can be selected for another. Bindings like so:

For the values themselves:

-> ValueSelection.Content
    Bind To: Value Source Entity
    Controller Key: arrangedObjects
    Model Key: N/A

For the values displayed in the NSPopUpButton:

-> ValueSelection.ContentValues
    Bind to: Same entity as ValueSelection.Content
    Controller Key: arrangedObjects
    Model Key: the name of the attribute you wish to have displayed

To link it to the destination value:

-> ValueSelection.SelectedObject
    Bind to: Destination entity
    Controller Key: selection
    Model Key: Name of the attribute/relationship in the destination entity.

What I'm trying to do is figure out if there is a way to set up a filter (I'm guessing in ContentValues) where you can only have it grab entries from that entity that have a certain attribute flag checked (e.g. say I'm pulling from my users entity and I just wanted to list male or female users).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

方觉久 2024-08-20 01:43:23

NSArrayController 有一个“过滤谓词",可以在 Interface Builder 或代码中设置(通过我链接的文档中的方法)。请参阅谓词编程指南弄清楚您需要为所需的过滤器提供什么谓词。

NSArrayController has a "filter predicate", which can be set in Interface Builder or in code (via the method in the docs to which I linked). See the Predicates Programming Guide to figure out what predicate you'll need to supply for your desired filter.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文