Code of ViewController (code of file from where you want to pass value):
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var txt1: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
@IBAction func ClickToPass(_ sender: Any) {
let mmi = self.storyboard?.instantiateViewController(withIdentifier: "Second") as! SecondViewController
mmi.passedvalue = txt1.text!
self.navigationController?.pushViewController(mmi, animated: true)
}
}
Code of SecondViewController (code of file where you want to get value):
import UIKit
class SecondViewController: UIViewController {
@IBOutlet weak var label1: UILabel!
var passedvalue = String()
override func viewDidLoad() {
super.viewDidLoad()
label1.text = "Passed value= " + passedvalue
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Screenshots:








Really helpful articles. I loved it
ReplyDeleteGood piece of information you shared. Loved it . Also, visit the site to learn about iOS app development services in India.
ReplyDeleteWonderful information! Loved it . Also, visit the site to learn about iOS app development services in India.
ReplyDeleteGreat read, very well written and easy to understand. I appreciate the effort put into this post and look forward to reading more soon here.
ReplyDeleteEvent Management Companies Hyderabad
Event Management Companies in Ahmedabad
Event Management Companies in Pune
Event Management Companies in Mumbai
Event Management Companies in Bangalore
Event Management Companies in Gurgaon
Event Management Companies in Delhi