为 Spotlight 元数据查询配置 NSPredicateEditor(RowTemplate)I'
我正在尝试配置 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 来进入 NIB,确认它仍然可以正确构建,然后使用 BBEdit 检查它。
I'm trying to configure an NSPredicateEditor
(in Interface Builder) to edit the predicate for an NSMetadataQuery
.
As a first step, I'm trying to configure an NSPredicateEditorRowTemplate
to accept key path(s) for the left-side expression, trying a single keyPath (kMDItemTextContent
) to get started.
I can't figure out how to get all the pieces into IB. I've selected the row template, and set "Left Exprs" to "Key Paths" in the IB Attributes Inspector. But, using Apple's PhotoSearch example as a model, it appears that I should enter a user-readable attribute name (say, "Content") here; I can't figure out how to bind it to "kMDItemTextContent
".
I've dissected the (correctly-configured) NIB in PhotoSearch(*), and inside it there is an NSKeyPathExpression
specifying a metadata attribute attached to an NSPopUpButton
/NSPopUpButtonCell
.
I can't figure out where to navigate in IB to find the NSPopUpButton
, and I'm not sure what I'd do to bind it to an NSExpression
.
Any help appreciated.
(*) In case you're wondering, I got inside the NIB by converting it to a XIB, confirming that it still builds correctly, then examining it with BBEdit.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现在 Interface Builder 中使用
NSPredicateEditor
和朋友是一项极其乏味的任务。因此,我在代码中完成所有行模板配置。对于您的情况,听起来您不需要自定义行模板子类,因此您可能可以这样做:
一旦获得模板,只需将其添加到谓词编辑器中:
至于翻译“
kMDItemTextContent< /code>”,如果它不会自动发生(我认为可能会发生),您可以使用
NSPredicateEditor
本地化选项 显示不同的名称。I've found that working with
NSPredicateEditor
and friends in Interface Builder is an exceedingly tedious task. For that reason, I do all of my row template configuration in code.For your situation, it doesn't sound like you need a custom row template subclass, so you could probably just do:
Once you've got the template, simply add it to the predicateEditor:
As for translating the "
kMDItemTextContent
", if it doesn't happen automatically (and I think it might), you could use theNSPredicateEditor
localization options to display a different name.