Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在cocoa中获取applescript的变量值?_Cocoa_Macos_Applescript - Fatal编程技术网

如何在cocoa中获取applescript的变量值?

如何在cocoa中获取applescript的变量值?,cocoa,macos,applescript,Cocoa,Macos,Applescript,NSlog仅显示音轨等级。如何获得名称、鞑靼人、塔尔布姆等的价值?” 提前感谢Applescript返回最后执行的语句的值。在本例中,这是trating。将包含所有值的语句放在末尾(例如,一个列表)。Applescript返回最后执行的语句的值。在本例中,这是trating。在末尾放一个包含所有值的语句(比如,一个列表)。我试图更改告诉应用程序“iTunes”设置mydata以获取播放列表1的曲目1的{persistent ID,name,Artister,album}的{persistent

NSlog仅显示音轨等级。如何获得名称、鞑靼人、塔尔布姆等的价值?”


提前感谢

Applescript返回最后执行的语句的值。在本例中,这是
trating
。将包含所有值的语句放在末尾(例如,一个列表)。

Applescript返回最后执行的语句的值。在本例中,这是
trating
。在末尾放一个包含所有值的语句(比如,一个列表)。

我试图更改告诉应用程序“iTunes”设置mydata以获取播放列表1的曲目1的{persistent ID,name,Artister,album}的{persistent ID,artist,album}获取mydata end tell,但结果为nullJust return
{tname,tartist,talbum,ttime,Tmitate,tsize,Tting}
。一旦你开始工作,你可能想尝试返回和处理一条记录而不是一个列表,这样你就不会依赖AppleScript代码和Cocoa代码之间一致的索引。我试图改变,告诉应用程序“iTunes”将mydata设置为获取{持久ID、名称、艺术家、专辑}播放列表1的曲目1的get mydata end tell,但结果为nullJust return
{tname、tartist、talbum、ttime、tbitrate、tsize、trating}
。一旦开始工作,您可能希望尝试返回和处理记录而不是列表,这样您就不会依赖AppleScript代码和Cocoa代码之间一致的索引。
    NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init] ;

 NSAppleEventDescriptor *eventDescriptor;
 NSAppleScript *script ;
 NSString* source ;
 NSDictionary* errorDic ;

 source=@"tell application \"iTunes\" \n"
 @"set tname to name of track 1 of playlist 1 \n"
 @"set tartist to artist of track 1 of playlist 1 \n"
 @"set talbum to album of track 1 of playlist 1 \n"
 @"set ttime to time of track 1 of playlist 1 \n"
 @"set tbitrate to bit rate of track 1 of playlist 1 \n"
 @"set tsize to size of track 1 of playlist 1 \n"
 @"set trating to rating of track 1 of playlist 1 \n"
 @"end tell";

 script = [[NSAppleScript alloc] initWithSource:source];
 eventDescriptor = [script executeAndReturnError:&errorDic];
 NSString* frontUrl = [eventDescriptor stringValue];
 NSLog(frontUrl);

 /*NSAlert *alert = [[NSAlert alloc]init];
 [alert setMessageText:frontUrl];
 [alert runModal];
 [alert release];*/

 [pool release] ;