//
// ViewController.swift
// Segues
//
// Created by John on 27/03/2018.
// Copyright © 2018 Rom and Ram. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var textField: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func buttonPressed(_ sender: Any) {
performSegue(withIdentifier: "goToSecondScreen", sender: self)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "goToSecondScreen" {
let destinationVC = segue.destination as! SecondViewController
destinationVC.textPassedOver = textField.text!
}
}
}
---------------------
SecondviewController.swift
//
// SecondViewController.swift
// Segues
//
// Created by John on 27/03/2018.
// Copyright © 2018 Rom and Ram. All rights reserved.
//
import UIKit
class SecondViewController: UIViewController {
var textPassedOver : String?
@IBOutlet weak var label: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
label.text = textPassedOver
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
---------------------------------