过滤出现在NSPopUpButton列表中的Core Data实体的条目

时间:2009-12-04 09:38:51

标签: cocoa core-data interface-builder nspopupbuttoncell

我熟悉如何将数据从一个Core Data实体提供到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实体中提取,我只是想列出男性或女性用户。)

1 个答案:

答案 0 :(得分:2)

NSArrayController有一个“filter predicate”,可以在Interface Builder或代码中设置(通过我链接的文档中的方法)。请参阅Predicates Programming Guide以确定您需要为所需过滤器提供的谓词。