2011-11-24 28 views
0

我試圖找回從目前的iTunes文件位置跟蹤與此腳本當前曲目文件位置:獲取iTunes上

on open info 
    tell application "iTunes" 
     set songLocation to get location of current track 
    end tell 
    return songLocation 
end open 

,然後代碼:

desc = [_getFileLocScript runScript:someScript]; 
result = [desc stringValue]; 
NSLog (@"%@", result); //it shows null value. 
NSLog (@"%@", desc); //it shows some numbers and key "alis". 

輸出:

<NSAppleEventDescriptor: 'alis'($000000000232000200000A4C656F7......FFFF0000$)> 

問題是,這個文件位置信息實際上是從iTunes的applescript返回的?

回答

1

Applescript樣式的路徑與您以前可能有點不同。因此,對你來說最簡單的事情就是在你喜歡的風格中找到一條道路。因此,在你的AppleScript代碼我想你的代碼行改成這樣得到一個斜槓分隔的字符串如。/Users/username/Desktop/somefile.txt

return posix path of songLocation 

然後,一旦你在可可的返回值,你可以看到desc是一個NSAppleEventDescriptor。所以,如果你在文檔中查看,你會發現它沒有「stringValue」方法,但是它有一個「string」方法,所以使用它。因此,將您的線路更改爲...

result = [desc string];