Invoking services from a command-line tool...
Invoking services from a command-line tool...
- Subject: Invoking services from a command-line tool...
- From: Hsu <email@hidden>
- Date: Mon, 2 Jun 2003 10:38:01 -0700
Hullo,
I'm trying to invoke a Service from a commandline tool (similar to the
Grab Service example from Cocoa Programming). The problem is that it
only works some of the time - I invoke NSPerformService, and sometimes
it just doesn't work (returns NO). I can't figure out why, though
sometimes adding in spurious NSLog statements helps :(
This is pseudo-psuedo code for what I'm doing... am I missing something?
int main (int argc, const char * argv[]) {
NSAutoReleasePool *pool = [[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
NSArray *types = [NSArray arrayWithObject:NSFilenamesPboardType];
NSArray *filenames = args; // Assume this is populated by file paths
[theApp registerServicesMenuSendTypes:types returnTypes:nil];
NSPasteboard *pb = [NSPasteboard pasteboardWithName:@"XShelver
Pasteboard"];
[pb declareTypes:types owner:nil];
[pb setPropertyList:filenames forType:NSFilenamesPboardType];
if (!NSPerformService( @"Add to XShelf", pb )) {
NSLog(@"Error adding to XShelf");
[pool release];
return 1;
}
[pool release];
return 0;
}
Karl
--
damn you and your devil's advocacy!
Homepage:
http://homepage.mac.com/khsu/index.html
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.