• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Help to debug NSPerformService..
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help to debug NSPerformService..


  • Subject: Help to debug NSPerformService..
  • From: Peter Teeson <email@hidden>
  • Date: Tue, 07 Jan 2014 22:57:41 -0500

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 Services Implementation Guide in the section on Using Services has a section on Validating Services Menu Items.
There is some sample code but I do not understand how to apply this for my very simple case.

I looked in the TextEdit code but did not find anything helpful.

Please explain what I should do to programatically accomplish this simple "Look Up In Dictionary" task.
Thanks for your help.

respect…

Peter


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Help to debug NSPerformService..
      • From: Ken Thomases <email@hidden>
  • Prev by Date: NSScrollView problem
  • Next by Date: Re: NSScrollView problem
  • Previous by thread: Re: NSScrollView problem
  • Next by thread: Re: Help to debug NSPerformService..
  • Index(es):
    • Date
    • Thread