このように、ViewController変数を宣言する2つの異なる方法を試してみましたが、同じ結果が得られたようです。しかし、私はdestinationVC変数の設定に違いがなければならないと感じます。もしそうでなければ、新しいオブジェクトを宣言するより簡単な方法を使用しないでしょうか?ViewControllerオブジェクトを宣言する2つの方法の違い
[segue.destination as as segue.destination as! ViewControllerName] ViewControllerNameを用い
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "changeCityName" {
let destinationVC = segue.destination as! ChangeCityViewController
destinationVC.delegate = self
}
}
は、[()] prepareForSegue
方法において
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "changeCityName" {
let destinationVC = ChangeCityViewController()
destinationVC.delegate = self
}
}
コードの画像を投稿しないでください。写真を実際のコードに置き換えて(あなたの質問にコピーして貼り付けて)、あなたの質問を編集してください。 – rmaddy