Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Providing a Service

Providing a Service
Thread Tools
Uncle Skeleton
Addicted to MacNN
Join Date: Nov 2002
Location: Rockville, MD
Status: Offline
Reply With Quote
Dec 22, 2009, 08:28 PM
 
I can't get services to work. I am trying to provide a service, just like in this website:
Mac Dev Center: Services Implementation Guide: Providing a Service

I copied that code to a new Cocoa app (except instead of rot13 I just NSLog the string). I copied the info.plist entry to my info.plist, replacing only "NewsReader" with my app's name "serv." That's it, then I moved my app to /Applications, ran it, quit it, and restarted the computer (core2duo imac, 10.5.8). Nothing is added to the Services menu of any other app, and running the suggested /Applications/TextEdit.app/Contents/MacOS/TextEdit -NSDebugServices com.yourcompany.serv logs nothing.

Has anyone ever managed to write a service before? What am I doing wrong?

Here's the entirety of my code:

Code:
@implementation serv - (void) applicationDidFinishLaunching:(NSNotification *)note { NSLog(@"launch"); [NSApp setServicesProvider:self]; } - (void)report:(NSString *)s { NSLog(s); } - (void)simpleEncrypt:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error { NSLog(@"simpleEncrypt"); NSString *s = [pboard stringForType:NSStringPboardType]; [self report:s]; } @end
Code:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleDevelopmentRegion</key> <string>English</string> <key>CFBundleExecutable</key> <string>${EXECUTABLE_NAME}</string> <key>CFBundleIconFile</key> <string></string> <key>CFBundleIdentifier</key> <string>com.yourcompany.serv</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>${PRODUCT_NAME}</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> <string>1.0</string> <key>NSMainNibFile</key> <string>MainMenu</string> <key>NSPrincipalClass</key> <string>NSApplication</string> <key>NSServices</key> <array> <dict> <key>NSKeyEquivalent</key> <dict> <key>default</key> <string>E</string> </dict> <key>NSMenuItem</key> <dict> <key>default</key> <string>Encrypt Text</string> </dict> <key>NSMessage</key> <string>simpleEncrypt</string> <key>NSPortName</key> <string>serv</string> <key>NSSendTypes</key> <array> <string>NSPasteboardTypeString</string> </array> <key>NSReturnTypes</key> <array> <string>NSPasteboardTypeString</string> </array> </dict> </array> </dict> </plist>
( Last edited by Uncle Skeleton; Dec 22, 2009 at 08:36 PM. )
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 06:25 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,