I am trying to use NSOperationQueue in ASOC.
I know how to use NSOperationQueue in Objective-C
Objective-C example:
//create operation queue
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
//add operation with block to operation queue
[queue addOperationWithBlock:^{
[NSThread sleepForTimeInterval:300.0];
}];
However, I don’t know how to do it in AppleScriptObjc.
This is the source I thought:
tell class "NSOperationQueue" of current application
set queue to NSOperationQueue's alloc()'s init()
queue's addOperationWithBlock_("delay 300")
end tell
But this didn’t work…(lldb error?), just as I thought.
Could anyone tell me how to use NSOperationQueue?
I use NSOperation because I want to stop “delay 300” from another method. But I don’t know I can stop it. Is this wrong? Can’t I stop “delay” with NSOperationQueue’s “cancelAllOperations”?
Sorry for my broken English.
Model: MacBook Air
AppleScript: 2.5.1
Browser: Safari 536.30.1
Operating System: Mac OS X (10.8)