1
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init] ;
NSAppleEventDescriptor *eventDescriptor;
NSAppleScript *script ;
NSString* source ;
NSDictionary* errorDic ;
[email protected]"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等的價值?'如何在可可中獲得可變的applescript值?
在此先感謝
我試圖改變 告訴應用程序 「iTunes」 的 \t集MYDATA獲得{永久ID,名稱,藝術家,專輯}播放列表的軌道1的1 \t得到MYDATA 端告訴 但結果爲空 – Irwan 2010-01-11 08:55:34
只需返回'{tname,tartist,talbum,ttime,tbitrate,tsize,trating}'。一旦你得到了這個工作,你可能想要嘗試返回並處理記錄而不是列表,這樣你就不會依賴AppleScript代碼和Cocoa代碼之間的索引。 – 2010-01-11 12:40:10
謝謝彼得!它正在工作 – Irwan 2010-01-11 13:21:56