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] ;
NSlog仅显示曲目评级。如何获得tname,tartist,talbum等的价值?'
提前致谢
答案 0 :(得分:1)
Applescript返回最后执行的语句的值。在这种情况下,那是trating
。在最后包含所有值(例如,列表)的语句。