ios - Segue identifier name mark as use of undeclared type -


i'm new ios development , i'm trying learn how pass data between viewcontrollers.

@ibaction func load3rdscreenpressed(_ sender: any) {     performsegue(withidentifier: "playsongsegue", sender: "hello") }  // in storyboard-based application, want little preparation before navigation override func prepare(for segue: uistoryboardsegue, sender: any?) {      if let destination = segue.destination as? playsongsegue {         if let song = sender as? string {             destination.selectedsong = song          }     } } 

on above code there's error message saying "use of undeclared type playsongsegue"

but have declared segue identifier. please point me out i'm doing wrong in this.

enter image description here

segue.destination of type uiviewcontroller, there need cast segue.destination uiviewcontroller subclass viewcontroller segueing has. looking @ screenshot seems playsongviewcontroller.

"playsongsegue" identifier of segue. can used if have several segues single viewcontroller check viewcontroller segueing to. checking identifier not needed use case, have added code anyways, since might need later on.

override func prepare(for segue: uistoryboardsegue, sender: any?) {      if segue.identifier == "playsongsegue", let destination = segue.destination as? playsongviewcontroller {         if let song = sender as? string {             destination.selectedsong = song          }     } } 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -