过滤出现在 NSPopUpButton 列表中的核心数据实体中的条目
我熟悉如何将一个核心数据实体中的数据馈送到 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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.