## Unexpectedly found nil while implicitly...
以下のエラーが出てしまいます。
error
1Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value
## コード
spaceshipVC
1import UIKit 2 3class SpaceshipVC: UIViewController { 4 5 var person : Person! 6 7 override func viewDidLoad() { 8 super.viewDidLoad() 9 print(person.name) // <-------エラー 10 11 // Do any additional setup after loading the view. 12 } 13}
上記、print
にてエラー。
下記のコードを実行させたいです。
HomeworldVC
でのprint(person.name)
は上手く実行できたのですが、
他3つのVCにて上手くいきません。
識別子は正しいです。
SelectPersonVC
1override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 2 if segue.identifier == "toHomeworld" { 3 if let destination = segue.destination as? HomeworldVC { 4 destination.person = person 5 } else if segue.identifier == "toVehicles" { 6 if let destination = segue.destination as? VehiclesVC { 7 destination.person = person 8 } 9 } else if segue.identifier == "toSpaceships" { 10 if let destination = segue.destination as? SpaceshipVC { 11 destination.person = person 12 } 13 } else if segue.identifier == "toFilms" { 14 if let destination = segue.destination as? FilmsVC { 15 destination.person = person 16 } 17 } 18 } 19 }
## 参考
Outlet
やAction
の連携は正常かと思います..
【Swift】nilじゃないのに「unexpectedly found nil〜」が出る
質問は以上です。
お時間あるときに、ご返信頂けましたら幸いです????
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/08/21 08:20