OSX/Cocoa:在右键菜单和服务列表中设置服务
我已遵循所有 Apple 文档来为右键单击菜单列表和服务列表设置服务:
- 我已制作了所有相关的 info.plist 条目。 (发送类型、端口名称、菜单标题、实例方法等)
- 我已经创建了处理服务的方法。
- 我在应用程序中添加了服务注册码。
- 我构建了我的应用程序,将其放入应用程序目录中,注销并重新登录。
尽管如此,我无法在任何菜单项中看到我的服务。
编辑** 这是我的 info.plist 的服务部分:
<key>NSServices</key>
<array>
<dict>
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>MyApp/Send to MyApp</string>
</dict>
<key>NSMessage</key>
<string>contentService</string>
<key>NSPortName</key>
<string>MyApp</string>
<key>NSSendTypes</key>
<array>
<string>NSStringPboardType</string>
<string>NSFileContentsPboardType</string>
</array>
</dict>
</array>
我做错了什么?提前致谢。
I have followed all the Apple documentation for setting up a service for a right click menu list and for the services list:
- I have made all the relevant info.plist entries. (send types, port name, menu title, instance method, etc.)
- I have created the method which handles services.
- I have added service registration code in the app.
- I built my app, put it in the application directory, logged out and back in.
Despite all this I cannot see my service in any menu item.
EDIT**
Here is the services part of my info.plist:
<key>NSServices</key>
<array>
<dict>
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>MyApp/Send to MyApp</string>
</dict>
<key>NSMessage</key>
<string>contentService</string>
<key>NSPortName</key>
<string>MyApp</string>
<key>NSSendTypes</key>
<array>
<string>NSStringPboardType</string>
<string>NSFileContentsPboardType</string>
</array>
</dict>
</array>
What am I doing wrong? thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
啊,这就是问题所在:你停在那里了。 您还需要将
NSRequiredContext
键添加到您的服务,以使其在 Snow Leopard 及更高版本上默认启用。幸运的是,虽然服务文档没有提到
NSRequiredContext
是必需的,信息属性列表关键参考确实解释了您必须为其提供的值。Ah, that's the problem: You stopped there. You also need to add the
NSRequiredContext
key to your service to get it to be enabled by default on Snow Leopard and later.Fortunately, while the Services documentation doesn't mention that
NSRequiredContext
is required, the Information Property List Key Reference does explain the value you must provide for it.