Luke_i Luke_i - 1 year ago 78
Swift Question

Show Label Value on 2nd View - Swift

Since i'm new and a newbie on Swift can someone tell me how I can get the label value on screen 1 to show on screen 2. Thanks

enter image description here

Edit: So I tried the way you told me but for some reason the Label text did not change in View 2. Any help? Thanks

enter image description here

enter image description here

Joe Joe
Answer Source

I am passing textFiled data to destViewController to show how segue performs when passing data.

Note: If you want to pass string data to your destVC.You can assign your string like var someValue: : String


enter image description here


  @IBOutlet weak var textField: UITextField! 
  //or you can assign string like var someValue: : String

  override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        let viewController = segue.destination as! destVC
        viewController.dataText = textField.text // someValue.text


@IBOutlet var label: UILabel!

var dataText = String()
override func viewDidLoad()      
label.text = dataText                 


enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download