daily pastebin goal
94%
SHARE
TWEET

Untitled

a guest Nov 17th, 2017 44 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import UIKit
  2.  
  3. class FirstViewController: UIViewController {
  4.     @IBOutlet weak var textField: UITextField!
  5.  
  6.     @IBAction func enter(_ sender: Any) {
  7.         if textField.text != "" {
  8.             if let window = UIApplication.shared.delegate?.window, let tabBarController = window?.rootViewController as? UITabBarController, let second = tabBarController.viewControllers?.first as? SecondViewController {
  9.                 second.label.text = textField.text
  10.                 tabBarController.selectedIndex = 0
  11.             }
  12.         }
  13.     }
  14.  
  15.     override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  16.  
  17.     }
  18.  
  19.     override func viewDidLoad() {
  20.         super.viewDidLoad()
  21.         // Do any additional setup after loading the view, typically from a nib.
  22.     }
  23.  
  24.     override func didReceiveMemoryWarning() {
  25.         super.didReceiveMemoryWarning()
  26.         // Dispose of any resources that can be recreated.
  27.     }
  28.  
  29.  
  30. }
  31.    
  32. import UIKit
  33.  
  34. class SecondViewController: UIViewController {
  35.  
  36.     @IBOutlet weak var label: UILabel!
  37.     var myString = String()
  38.  
  39.     override func viewDidLoad() {
  40.         super.viewDidLoad()
  41.  
  42.         label.text = myString
  43.         // Do any additional setup after loading the view, typically from a nib.
  44.     }
  45.  
  46.     override func didReceiveMemoryWarning() {
  47.         super.didReceiveMemoryWarning()
  48.         // Dispose of any resources that can be recreated.
  49.     }
  50.  
  51.  
  52. }
RAW Paste Data
Top