因此,我有一个简单的applescript,它返回(返回"test")以下内容:
测试:‘utxt’(“NSAppleEventDescriptor”)
我发现了this问题,并尝试用下面的代码复制它所做的事情
NSAppleScript *scriptObject = [[NSAppleScript alloc]initWithContentsOfURL:[NSURL fileURLWithPath: scriptPath]
error:&error];
returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
NSLog(@"Return Discriptor,%@",returnDescriptor);
NSAppleEventDescriptor *utxt = [returnDescriptor descriptorForKeyword:'utxt'];
NSLog(@"Found utxt Discriptor: %@",utxt);
NSString *scriptReturn = [utxt stringValue];
NSLog(@"Found utxt string: %@",scriptReturn);但它没有返回任何内容:
返回描述符,找到utxt描述符:(null)找到utxt字符串:(null)
发布于 2011-07-22 07:54:11
在我看来,returnDescriptor已经是描述符了,你不需要这个: returnDescriptor descriptor descriptor:‘utxt’;。我没有测试这段代码,但试一试...
NSDictionary *errorDict = nil;
NSAppleScript *scriptObject = [[NSAppleScript alloc]initWithContentsOfURL:[NSURL fileURLWithPath:scriptPath] error:&errorDict];
if (errorDict) {
NSLog(@"Error: %@", errorDict);
return;
}
NSAppleEventDescriptor *returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
if (errorDict) {
NSLog(@"Error: %@", errorDict);
[scriptObject release];
return;
}
NSString *scriptReturn = [returnDescriptor stringValue];
NSLog(@"Found utxt string: %@",scriptReturn);
[scriptObject release];https://stackoverflow.com/questions/6780910
复制相似问题