On Jan 7, 2014, at 9:57 PM, Peter Teeson wrote: > OS X 10.8.5, Xcode 5.0.2, Document app > > In my app I have this: > @interface Guess : NSTextField // populated programmatically > … > -(void)check; // method to programatically use the Service "Look Up In > Dictionary" > @end > > @implementation Guess > ... > -(void)check { // Lookup word in dictionary > [self selectText:nil]; > NSString *theString = [self stringValue]; // debug shows ( > _NSCFString*) @"THERE" > NSArray *toLookup = [NSArray arrayWithObjects:theString,nil]; // debug > shows (_NSArray *) @"1 object" > NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; // debug > shows (NSPasteboard *) 0x10011a7b0 > NSInteger changeCount = [pasteboard clearContents]; // debug shows > (NSInteger) 9 > BOOL OK = [pasteboard writeObjects:toLookup]; // debug shows (BOOL) YES > > // ********** This is my problem > BOOL res = NSPerformService(@"Look Up In Dictionary", pasteboard); // > debug shows (BOOL) NO > } > ... > @end > > If I manually select the text in the field by double clicking it, the > Services menu is populated and does contain > "Look Up In Dictionary".
The slight bit of example code from Apple showing a use of NSPerformService() uses +pasteboardWithUniqueName, not + generalPasteboard. You could try that. https://developer.apple.com/library/mac/samplecode/PhotoSearch/Listings/MainWindowController_m.html Also, you can try launching your app with "-NSDebugServices com.apple.Dictionary" to see if that's informative. That said, perhaps you're actually looking for the -[NSView showDefinitionForAttributedString:…] methods. Regards, Ken _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com