遷移先のhelloButtonを押したら最初の画面のfastLabel.textに”HelloHello”と表示したいのですが
エラーになります。。。。なぜなのでしょうか。。。
swift
1import UIKit 2 3class ViewController: UIViewController { 4 static let share = ViewController() 5 6 @IBOutlet weak var fastLabel: UILabel! 7 8 override func viewDidLoad() { 9 super.viewDidLoad() 10 // Do any additional setup after loading the view. 11 } 12 13 14}
swift
1import UIKit 2 3class NextViewController: UIViewController { 4 5 override func viewDidLoad() { 6 super.viewDidLoad() 7 8 } 9 10 @IBAction func helloButton(_ sender: UIButton) { 11 ViewController.share.fastLabel.text = "HelloHello" 12 //eller!! Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value 13 14 } 15 16 17}
マルチポスト : スタックオーバー

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。