0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Swift]画面遷移先に値を送る

Last updated at Posted at 2021-04-04
 override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        let x = 10
        let test = segue.destination as! A //遷移先の画面のscriptファイル名
        test.x = x
    }

let test = segue.destination as! A
test.x = x

とすることで、遷移先の画面に対して変数を参照できるようになる。

つまり、
現在の遷移元であるフィールド変数xを遷移先Aのフィールド変数xに代入できる

override func prepare(for segue: UIStoryboardSegue, sender: Any?)
は遷移というアクションが発生すると呼び出されるのか
。。。
今はそういうことにしておこう

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?