I used this code in Objective C:
@implementation KDOrderInfo
- (id)performDefaultImplementation {
NSString *theRequest = [self directParameter];
NSDictionary *arguments = [self evaluatedArguments];
NSLog(@"arguments = %@ %ld",arguments, [arguments count]);
NSLog(@"theRequest----> %@",theRequest);
/*.......
.....*/
return @YES
}
This code works OK in Objective C. I converted this code to Swift code as follows:
class OrderInfo : NSScriptCommand {
override func performDefaultImplementation() -> AnyObject! {
let theRequest: AnyObject! = self.directParameter
let arguments = self.evaluatedArguments
println("arguments = \(arguments) argumentsCount = \(arguments.count)")
println("theRequest----> \(theRequest)")
/*.......
.....*/
return "OK"
}
}
when I run my applescript then I get the error (InfoMaker is the name of my app): InfoMaker got an error: The handler some object is not defined.
The method :
override func application(theApp:NSApplication,delegateHandlesKey theKey:String) -> Bool{
println("scripting key = \(theKey)");
let thekeys = ["pathToXML", "saveXMLFlag", "webserviceName","methodName","pathToInfoFiles","fileToCheck","scriptingProperties"]
if thekeys.containsString(theKey.lowercaseString, searchcase:NSStringCompareOptions.CaseInsensitiveSearch) {
//[self prefsToVars];
println("YES")
return true;
} else {
println("NO")
return false
}
}
in my app delegate responds OK to the applescript.
I tried also with the "SimpleScriptingVerbs" example from Apple and I get the same error in my Swift implementation. I hope somebody can help find the problem and have a suggestion.