[swift] 異なるStoryBoardに遷移する時に値を渡す方法
異なるStoryBoardに遷移する時に値を渡す方法は以下の通り
*異なるStoryBoardに遷移させる方法はこちら
AppDelegate.swift
class AppDelegate: UIResponder, UIApplicationDelegate {
var [変数]: String?
//以下略
}
遷移元:
override func viewWillDisappear(animated: Bool) {
super.viewDidDisappear(animated)
var appDelegate: AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.[変数] = [受け渡したい値]
}
遷移先:
override func viewWillAppear(animated: Bool) {
super.viewDidDisappear(animated)
var appDelegate: AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
[受け取りたい値] = appDelegate.[変数]
}