我正在尝试配置一个NSPredicateEditor
(在 Interface Builder 中)编辑谓词NSMetadataQuery
.
作为第一步,我尝试配置一个NSPredicateEditorRowTemplate
接受左侧表达式的关键路径,尝试使用单个 keyPath (kMDItemTextContent
) 开始。
我不知道如何将所有部分都放入 IB 中。我选择了行模板,并在 IB 属性检查器中将“Left Exprs”设置为“Key Paths”。但是,使用 Apple 的 PhotoSearch 示例作为模型,看来我应该在此处输入用户可读的属性名称(例如“内容”);我不知道如何将它绑定到“kMDItemTextContent
".
我已经在 PhotoSearch(*) 中剖析了(正确配置的)NIB,里面有一个NSKeyPathExpression
指定附加到的元数据属性NSPopUpButton
/NSPopUpButtonCell
.
我不知道在 IB 中导航到哪里才能找到NSPopUpButton
,而且我不确定我会做什么来将它绑定到NSExpression
.
任何帮助表示赞赏。
(*) 如果您想知道,我通过将 NIB 转换为 XIB 来了解它,确认它仍然可以正确构建,然后使用 BBEdit 检查它。
我发现与NSPredicateEditor
和朋友们一起使用 Interface Builder 是一项极其乏味的任务。因此,我在代码中完成所有行模板配置。
对于您的情况,听起来您不需要自定义行模板子类,因此您可能可以这样做:
#define NSPERT NSPredicateEditorRowTemplate
NSPERT * template = [[NSPERT alloc] initWithLeftExpressions:[NSArray arrayWithObject:[NSExpression expressionForKeyPath:kMDItemTextContent]]
rightExpressionAttributeType:NSStringAttributeType
modifier:NSDirectPredicateModifier
operators:[NSArray arrayWithObject:
[NSNumber numberWithUnsignedInteger:NSContainsPredicateOperatorType]]
options:(NSCaseInsensitivePredicateOption|NSDiacriticInsensitivePredicateOption)];
获得模板后,只需将其添加到 predicateEditor 中即可:
NSMutableArray * templates = [[myPredicateEditor rowTemplates] mutableCopy];
[templates addObject:template];
[template release];
[myPredicateEditor setRowTemplates:templates];
[templates release];
至于翻译“kMDItemTextContent
“,如果它不会自动发生(我认为它可能会发生),你可以使用NSPredicateEditor本地化选项 http://funwithobjc.tumblr.com/post/1482915398/localizing-nspredicateeditor显示不同的名称。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)