开发者

OSX/Cocoa : setting up service in menu for right click and services list

开发者 https://www.devze.com 2023-04-09 15:50 出处:网络
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 followed all the Apple documentation for setting up a service for a right click menu list and for the services list:

  1. I have made all the relevant info.plist entries. (send types, port name, menu title, instance method, etc.)
  2. I have created the method which handles services.
  3. I have added service registration code in the app.
  4. 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</开发者_StackOverflow中文版key>
        <array>
            <string>NSStringPboardType</string>
            <string>NSFileContentsPboardType</string>
        </array>
    </dict>
</array>

What am I doing wrong? thanks in advance.


I have followed all the Apple documentation for setting up a service…

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号