• 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
Re: Help to debug NSPerformService..
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help to debug NSPerformService..


  • Subject: Re: Help to debug NSPerformService..
  • From: Ken Thomases <email@hidden>
  • Date: Tue, 07 Jan 2014 22:18:00 -0600

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 (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: Peter Teeson <email@hidden>
References: 
 >Help to debug NSPerformService.. (From: Peter Teeson <email@hidden>)

  • Prev by Date: Re: NSScrollView problem
  • Next by Date: Re: BT data (NSData *) question
  • Previous by thread: Help to debug NSPerformService..
  • Next by thread: Re: Help to debug NSPerformService..
  • Index(es):
    • Date
    • Thread