Applescript ScriptingBridge iTunesTrack与iTunesFileTrack-沙盒错误

Applescript ScriptingBridge iTunesTrack与iTunesFileTrack-沙盒错误,applescript,itunes,scripting-bridge,applescript-objc,Applescript,Itunes,Scripting Bridge,Applescript Objc,我有一个AppleScript ObjC应用程序,它是沙盒式的,我在尝试获取或设置iTunes曲目的属性时遇到了问题。奇怪的是,在使用iTunesTrack对象时,我可以成功地运行get/set方法,但在使用iTunesFileTrack对象时却不能 例如: set iTunesAppObject to current application's SBApplication's applicationWithBundleIdentifier_("com.apple.iTunes")

我有一个AppleScript ObjC应用程序,它是沙盒式的,我在尝试获取或设置iTunes曲目的属性时遇到了问题。奇怪的是,在使用iTunesTrack对象时,我可以成功地运行get/set方法,但在使用iTunesFileTrack对象时却不能

例如:

    set iTunesAppObject to current application's SBApplication's applicationWithBundleIdentifier_("com.apple.iTunes")
    set trackToEdit to iTunesAppObject's currentTrack()
    set trackPersistentID to trackToEdit's persistentID()
    trackToEdit's setName_("TEST NAME") -- this works, trackToEdit is an iTunesTrack object

    -- GET ALL SOURCES FROM ITUNES
    set iTunesSources to iTunesAppObject's sources()

    -- REPEAT FOR EVERY SOURCE
    repeat with aSource in iTunesSources

        -- LOOK FOR MAIN LIBRARY SOURCE
         if (aSource's |kind|()) is 1.800169826E+9 then
             set mainLibrary to aSource
             exit repeat
         end if

    end repeat

    set libraryPlaylist to mainLibrary's |libraryPlaylists|() -- GET LIBRARY PLAYLIST
    set libraryPlaylist to libraryPlaylist's objectAtIndex_(0)
    set allTracksInPlaylist to libraryPlaylist's |fileTracks|() -- GET ALL TRACKS IN PLAYLIST

    -- SET UP PREDICATE TO FIND TRACK WITH ID
    set searchPredicate to current application's NSPredicate's predicateWithFormat_(("persistentID == " & quoted form of (trackPersistentID as text)))
    allTracksInPlaylist's filterUsingPredicate_(searchPredicate) -- FILTER ARRAY
    set trackToEdit to allTracksInPlaylist's objectAtIndex_(0) -- GET REMAINING ITEM IN ARRAY, RETURNS iTunesFileTrack OBJECT


log trackToEdit -- returns a seemingly valid iTunesFileTrack object     
trackToEdit's setName_("TEST NAME") -- does NOT work, result in sandbox dispatch deny error in Console.app
log trackToEdit's |name|() -- does NOT work, returns null/missing value
当应用程序没有沙盒时,一切都正常。我几乎为我的项目增加了所有权利,包括:

com.apple.iTunes.library.read-write
com.apple.iTunes.user-interface
com.apple.iTunes.playerInfo
com.apple.iTunes.playback

有人能想出一个办法来解决这个问题吗?是否可以将iTunesFileTrack对象“转换”为iTunesTrack对象?提前感谢您的建议

祝福你的心。试试这个:

property aTrack : missing value

on getTrack_(sender)

tell application "iTunes"
set aTrack to (get current track)
end tell

end getTrack_

on renameTrack_(sender)
set name of aTrack to "whatever"
end renameTrack_

我欠你一些翅膀,兄弟。我把球放下,忘了在水里拉屎了。