AppleScriptObjC:无法创建 AVMIDIPlayer 对象

AppleScriptObjC: Can't create AVMIDIPlayer object

我在使用 AppleScript ObjC 代码时遇到了一些问题。问题行似乎是在我初始化 AVMIDIPlayer 对象时(第 3 行重复)。它返回 -1 错误,(AVAudioEngineManualRenderingStatusError)。下一行然后失败,因为 Nil 对象没有任何方法。

这里是相关位:

property NSURL : a reference to current application's NSURL
property AVMIDIPlayer : a reference to current application's AVMIDIPlayer
on open (filelist)
    repeat with each_item in filelist
        set myfile to quoted form of POSIX path of each_item as string
        set myMIDIFile to (NSURL's fileURLWithPath:myfile)
        set {myMIDIPlayer, theError} to (AVMIDIPlayer's alloc()'s initWithContentsOfURL:myMIDIFile soundBankURL:none |error|:(reference))
        myMIDIPlayer's prepareToPlay()
        myMIDIPlayer's play(myHandler)

问题的原因是quoted form of

仅在 do shell script 中使用它来转义包含空格和特殊字符的字符串,别处没有。

set myfile to POSIX path of each_item -- no coercion: POSIX path is string

并处理theError