-
Notifications
You must be signed in to change notification settings - Fork 0
pass data from ViewControllers to another ViewController 1
Mohammad Azmal Hossain edited this page Mar 12, 2017
·
3 revisions
-
take two viewController and join them by showSegue
-
first class
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var textField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let destViewController = segue.destination as! SecondViewController
destViewController.labelText = textField.text
}
}
-
second class
import UIKit
class SecondViewController: UIViewController {
@IBOutlet weak var previewLabel: UILabel!
var labelText: String!
override func viewDidLoad() {
super.viewDidLoad()
previewLabel.text = labelText
} }