0
我對ios開發非常陌生,我試圖學習如何在ViewControllers之間傳遞數據。Segue標識符名稱標記作爲未聲明類型的使用
@IBAction func load3rdScreenPressed(_ sender: Any) {
performSegue(withIdentifier: "PlaySongSegue", sender: "Hello")
}
// In a storyboard-based application, you will often want to do a 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
}
}
}
在上面的代碼中有一個錯誤信息,說「使用未申報類型PlaySongSegue
的」
但我已經宣佈這個SEGUE標識符。請指出我在這做錯了什麼。
什麼是你正在導航的VC的類名(swift文件)? –
注意行:if let destination = segue.destination as? ** [你的目的地視圖控制器] **,我假設你的情況是PlaySongViewController – Hooda