Swift 音频传递给另一个 ViewController
Swift Audio passing to another ViewController
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "stopRecording" {
let playSoundsVC = segue.destination as! PlaySoundsViewController
let recordedAudioURL = sender as! URL
playSoundsVC.receivedAudio = recordedAudioURL
}
}
问题是我的 Xcode 生成错误
Value of type 'PlaySoundsViewController' has no member 'receivedAudio'
要使其正常工作,目标 VC 应如下所示
class PlaySoundsViewController:UIViewController {
var receivedAudio:URL?
.....
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "stopRecording" {
let playSoundsVC = segue.destination as! PlaySoundsViewController
let recordedAudioURL = sender as! URL
playSoundsVC.receivedAudio = recordedAudioURL
}
}
问题是我的 Xcode 生成错误
Value of type 'PlaySoundsViewController' has no member 'receivedAudio'
要使其正常工作,目标 VC 应如下所示
class PlaySoundsViewController:UIViewController {
var receivedAudio:URL?
.....
}