Lev*_*ink 3 macos cocoa objective-c
我需要在服务菜单中默认启用我创建的服务.
我为我的OS X应用程序(在Snow Leopard上运行)创建了一项服务.我已经像这样配置了Info.plist:
<key>NSServices</key>
<array>
<dict>
<key>NSSendTypes</key>
<array>
<string>NSStringPboardType</string>
</array>
<key>NSMessage</key>
<string>dropService</string>
<key>NSMenuItem</key>
<dict>
<key>default</key>
<string>Drop Service</string>
</dict>
<key>NSPortName</key>
<string>MyApp</string>
</dict>
</array>
Run Code Online (Sandbox Code Playgroud)
到目前为止,我遵循以下其他步骤:http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/SysServices/introduction.html,一切似乎都正常.
我跑了命令:
/System/Library/CoreServices/pbs
Run Code Online (Sandbox Code Playgroud)
现在我的服务显示在"系统偏好设置 - >键盘 - >键盘快捷键 - >服务"下.所以系统知道它.但它不会显示在服务菜单中,除非我手动激活它.
当我尝试调试服务时,我收到以下消息:
/Applications/TextEdit.app/Contents/MacOS/TextEdit -NSDebugServices com.myapp.MyApp
Drop Service (com.myapp.MyApp) is disabled in the services menu and disabled in the context menu, by the standard Services policy.
Run Code Online (Sandbox Code Playgroud)
我不知道"标准服务政策"是什么,我在Apple开发者网站上找不到任何对此错误的引用.
我认为自动启用服务项是不可能的,但我已经确认某些应用程序会这样做(比如来自文化代码的东西)所以我知道它可以完成.
有任何想法吗?
Nic*_*ore 11
只需在Info.plist中添加一个带有空白字典的NSRequiredContext键作为其对象.这是它应该看起来的样子:
<key>NSRequiredContext</key>
<dict>
</dict>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3772 次 |
最近记录: |