不匹配任何可用的重载 (FileURLWithPath)

Do not match any available overloads (FileURLWithPath)

我无法让这段代码工作,我一直收到一条错误消息:

Argument labels '(FileURLWithPath:)' do not match any available overloads

do {
    audioPlayer = try
        AVAudioPlayer(contentsOf:
            URL(FileURLWithPath: sound!))
    audioPlayer.prepareToPlay()
} catch {
    print("error")
}

你有什么建议吗?

提到的错误Argument labels '(FileURLWithPath:)' do not match any available overloads是相当值得注意的。

替换

AVAudioPlayer(contentsOf: URL(FileURLWithPath: sound!))

AVAudioPlayer(contentsOf: URL(fileURLWithPath: sound!))