我所做的是在可可里面执行一个applescript。它以nsappleeventdescriptor的形式返回一些数据,nslog()按如下方式打印:

<NSAppleEventDescriptor: 'obj '{ 'form':'name', 'want':'dskp', 'seld':'utxt'("69671872"), 'from':'null'() }>

我想把这些数据转换成一个nsdictionary或nsarray,或者一些有用的东西,这样我就可以从中提取数据(特别是我在使用“69671872”数字的字段之后)。这似乎是一系列的问题,但我对苹果事件的了解相当有限。你知道怎么做吗?
以下是创建上述数据的源:
NSString *appleScriptSource = [NSString stringWithFormat:@"tell application\"System Events\"\n return desktop 1\n end tell"];
NSDictionary *anError;
NSAppleScript *aScript = [[NSAppleScript alloc] initWithSource:appleScriptSource];
NSAppleEventDescriptor *aDescriptor = [aScript executeAndReturnError:&anError];

NSLog (@"%@", aDescriptor);
[aScript release];

提前感谢您的帮助!:)

最佳答案

[[aDescriptor descriptorForKeyword:keyAEKeyData] stringValue]

07-26 09:35
查看更多