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?

More than 3 years have passed since last update.

delegateの設定、dismiss 備忘録

Posted at

遷移前の変数、配列を遷移後のコードでも使用したい場合、delegateまたはシングルトンを使うといい

delegateの使い方

//遷移前コード
let vc = R.storyboard.storyboard.menuView()!
vc.delegate = self
self.present(vc, animated: true, completion: nil)
//遷移後コード
var delegate : ViewController?

//自分自身を閉じる(破棄する)
self.dismiss(animated: true, completion: {
//クロージャー 
//self.delegate?.遷移前の実行したい関数
})

let vc = R.storyboard.main.main()!
self.present(vc, animated: true, completion: nil)

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?