如何模仿Finder NSPredicateEditor leftExpression列表

Tho*_*enC 6 cocoa objective-c nspredicateeditor

我想模仿Finder的谓词列表.特别是LeftExpressions弹出窗口带有"其他"(德语:"Andere ...")菜单条目,并且喜欢用用户可选择的搜索谓词列表弹出NSSheet.

我的方法是使用名为"other ..."的leftExpression创建一些NSPredicateEditorRowTemplates和一个最后一个自定义rowTemplate.

然后我重写templateViews方法并添加了separatorItem:

-(NSArray *)templateViews{
 NSMutableArray * views = [[super templateViews] mutableCopy];

// I tried already to add here my custom menu entry, but if I add more templates my custom entry (and the separator line) is not fixed at the last index.
if (!isCustomMenuItemAdded) {

NSPopUpButton *leftButton = views[0];

    // Add a menu separator
[[leftButton menu]insertItem:[NSMenuItem separatorItem] atIndex:[leftButton menu].itemArray.count-1];   
}
return views;
}
Run Code Online (Sandbox Code Playgroud)

我的自定义predicateEditor现在显示正确,但是如果我点击最后一个菜单项'Other ..',则显示虚拟NSPredicateRowTemplate.

我试图在我的rowTemplate类中覆盖 - (id)复制方法来抑制新行,但这对我来说很奇怪.

-(id)copy{
  return nil;  // OK, now there is no new row, but this throws an internal exception
}
Run Code Online (Sandbox Code Playgroud)

我的问题是:有没有更好的方法在左侧表达式popupButton中添加自定义菜单项?如何抑制PredicateEditor中显示新的predicateTemplateRow?