Search code examples
swiftxcodeaudiosegueviewcontroller

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               
    }
}

The question is that my Xcode generating error

Value of type 'PlaySoundsViewController' has no member 'receivedAudio'


Solution

  • For this to work the destinationVC should look like this

    class PlaySoundsViewController:UIViewController {
    
        var receivedAudio:URL?
    
        .....
     }