Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- class FirstViewController: UIViewController {
- @IBOutlet weak var textField: UITextField!
- @IBAction func enter(_ sender: Any) {
- if textField.text != "" {
- if let window = UIApplication.shared.delegate?.window, let tabBarController = window?.rootViewController as? UITabBarController, let second = tabBarController.viewControllers?.first as? SecondViewController {
- second.label.text = textField.text
- tabBarController.selectedIndex = 0
- }
- }
- }
- override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
- }
- 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.
- }
- }
- import UIKit
- class SecondViewController: UIViewController {
- @IBOutlet weak var label: UILabel!
- var myString = String()
- override func viewDidLoad() {
- super.viewDidLoad()
- label.text = myString
- // 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.
- }
- }
Add Comment
Please, Sign In to add comment