Swift音频传递给另一个ViewController

时间:2018-07-27 11:56:05

标签: swift xcode audio segue 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生成错误

  

“ PlaySoundsViewController”类型的值没有成员“ receivedAudio”

1 个答案:

答案 0 :(得分:0)

为此,destinationVC应该看起来像这样

class PlaySoundsViewController:UIViewController {

    var receivedAudio:URL?

    .....
 }