• 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: AppleScriptability Meets NSOperation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScriptability Meets NSOperation


  • Subject: Re: AppleScriptability Meets NSOperation
  • From: Jerry Krinock <email@hidden>
  • Date: Mon, 29 Mar 2010 16:34:06 -0700

On 2010 Mar 29, at 14:30, has wrote:

> The Apple Event Manager supports suspend and resume

Great tip, has.  I searched and found
   Cocoa Scripting Guide
      How Cocoa Applications Handle Apple Events
         Suspending and Resuming Apple Events and Script Commands

In there, it looks like -suspendExecution and -resumeExecutionWithResult: have been provided for my situation exactly.  (I am using Cocoa Scripting and NSScriptCommand.)

And it appears that we have solved the problem.  But since I couldn't find any sample code using -suspendExecution or -resumeExecutionWithResult:, I shall describe this so I can find it in the list archives next time I forget :)

In my subclass' implementation of performDefaultImplementation:,

    [[SSYOperationQueue mainQueue] setScriptCommand:self] ;
    [self suspendExecution] ;

In the first line, I stash the command away in an ivar for later, which is necessary because -suspendExecution causes -currentCommand to subsequently return nil.

Then in my asynchronous completion routine,

    NSScriptCommand* scriptCommand = [[SSYOperationQueue maenQueue] scriptCommand] ;

    if (!ok) {
        [scriptCommand setScriptErrorNumber:errorValue] ;
        [scriptCommand setScriptErrorString:errorString] ;
    }

    [scriptCommand resumeExecutionWithResult:nil] ;

Seems to work perfectly, although it's kind of spooky how it works.  Maybe they're setting up a sleeping thread for me behind the scenes.

And thank you very much has!!  You really kept me from making a big mistake today.

_______________________________________________

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

References: 
 >Re: AppleScriptability Meets NSOperation (From: has <email@hidden>)

  • Prev by Date: CIFilter and grayscale image
  • Next by Date: Re: Removing Object form ArrayController without managedObjectContext
  • Previous by thread: Re: AppleScriptability Meets NSOperation
  • Next by thread: CALayer Grid jerky animation
  • Index(es):
    • Date
    • Thread