Peter;

Turns out my issue was not related to the Info.plist at all.
The confusion about 'default' label on the 'Services' menu has to do with how Finder handles dropping a .plist into .txt field...

My service 'MyService' does indeed need to subclass NSApplication.
I just quit fighting against the tide and added an empty nib. -- Presto!

So now my working stand alone service provider consists of merely 6 small items:
1) an .icns file
2) an empty IB generated nib file - completely unmodified (v2 NIB in my case [Tiger compatible]) (adding a NIB allows me to just use the standard main.m 'return NSApplicationMain(argc, (const char **) argv);'
3) main.m  - the usual Cocoa version  (however see question below)
3) an Info.plist (Principal class set to 'MyService' and the standard 'Services' specification.
4) a MyService.h file which sublclasses NSApplication
5) the MyService.m file for the file above.  This does 3 things:
        - in init [NSApp setDelegate:self];
        - in 'AppDidFinishLaunch' [NSApp setServiceProvider:self];
        - provides the required method(s) for providing a service:
- (void) seviceName:(NSPasteboard *)pboard userData:(NSString *)userData error:(NSString **)error

*** 2 Questions
-- I am operating on the presumption that this standalone service should terminate after providing its service but I can see an argument for not doing so. It's pretty lightweight (one class (~100 lines of ObjC) and an empty nib).
Do you have any guidance to offer here.
Since there is no interface to this service, what is the standard UI support for termination?

-- In the past, I have used the following main.m to log data to specific files:
int main(int argc, char *argv[]) {
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];     
freopen([[NSHomeDirectory() stringByAppendingPathComponent:@"Library/ Logs/com.mycompany.myapp.log"] fileSystemRepresentation], "w", stderr);
        [pool release];
        return NSApplicationMain(argc,  (const char **) argv);
}

But here my log statements are ending up in the console log.
Is there a way I can easily route log statements in MyService to a specific file?

Hope to get some feedback on these questions and that this posting eventually proves useful to someone else.

Steve


On Feb 4, 2009, at 5:10 PM, Peter Ammon wrote:


On Feb 4, 2009, at 1:23 PM, Steve Cronin wrote:

                        <key>NSMenuItem</key>
                        <dict>
                                <key>Menu item title</key>
                                <string>MyService</string>
                        </dict>

The key here needs to be "default" instead of "Menu item title".

This is a dictionary because it used to be keyed by localization, with "default" the value for an unknown loc. Now we use the ServicesMenu.strings file for localization, but the dictionary remains.

-Peter


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to