tags:

views:

183

answers:

2

Hi,

I've been trying to get NSServices working for my application recently with no success. I have set it up according to the documentation but it does not appear in the services menu ( however it does appear in the keyboard shortcuts section of the System Preferences as a service menu item) Anyway I set the service in my app controller like this:

[NSApp setServicesProvider:self];

The method exposed is:

- (void) addDownloadService:(NSPasteboard *)pboard

     userData:(NSString *)userData error:(NSString **)error

My Info.plist then looks like this:

<key>NSServices</key>
        <array>
                <dict>
                        <key>NSReturnTypes</key>
                        <array>
                                <string></string>
                        </array>
                        <key>NSKeyEquivalent</key>
                        <dict>
                                <key>English</key>
                                <string>S</string>
                                <key>Key equivalent (with command and shift)</key>
                                <string>S</string>
                        </dict>
                        <key>NSSendTypes</key>
                        <array>
                                <string>NSStringPboardType</string>
                                <string>NSURLPboardType</string>
                                <string>NSRTFPboardType</string>
                        </array>
                        <key>NSPortName</key>
                        <string>MyApp</string>
                        <key>NSMessage</key>
                        <string>addDownloadService</string>
                        <key>NSMenuItem</key>
                        <dict>
                                <key>English</key>
                                <string>MyNewService</string>
                                <key>default</key>
                                <string> MyNewService </string>
                        </dict>
                </dict>
        </array>

I tried running the debug command with textedit like so: /Applications/TextEdit.app/Contents/MacOS/TextEdit -NSDebugServices com.companyname.MyApp

which outputs the following: MyNewService (com.companyname.MyApp) is disabled in the services menu and disabled in the context menu, by the standard Services policy.

Anyone any ideas why it might not be working?

Thanks Colin

A: 

I have just gone trough the same problem. It seems that Snow Leopard disables the third party services by default.

You have to open the Preferences> Keyboard Select the second tab (fast something, I don't remember right now) select the Services, look for yours, and activate it.

There is no other workaround that I am aware of.

+1  A: 

You need to specify a list of required contexts using NSRequiredContext. This can be empty.

See http://lists.apple.com/archives/Cocoa-dev/2009/Sep/msg00201.html

NeilInglis