Advertisement
Guest User

SwiftEx

a guest
Jun 7th, 2021
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 1.64 KB | None | 0 0
  1. ViewController:
  2.  
  3. //
  4. //  ViewController.swift
  5. //  MultiView
  6. //
  7. //
  8.  
  9. import UIKit
  10.  
  11. class ViewController: UIViewController {
  12.    
  13.     @IBAction func Go(_ sender: UIButton) {
  14.        
  15.         self.performSegue(withIdentifier: "goToSecond", sender: self)
  16.        
  17.     }
  18.    
  19.     override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  20.         if segue.identifier == "goToSecond" {
  21.             let destination = segue.destination as! SecondViewController
  22.             destination.username = "Test"
  23.         }
  24.     }
  25.  
  26.    
  27.     override func viewDidLoad() {
  28.         super.viewDidLoad()
  29.         // Do any additional setup after loading the view.
  30.     }
  31.  
  32.  
  33. }
  34.  
  35. class ViewController2Class : UIViewController {
  36.     @IBAction func Close(_ sender: UIButton) {
  37.         self.dismiss(animated: true, completion: nil)
  38.     }
  39.    
  40.     override func viewDidLoad() {
  41.         super.viewDidLoad()
  42.         // Do any additional setup after loading the view.
  43.     }
  44.    
  45. }
  46.  
  47.  
  48. //
  49. //  SecondViewController.swift
  50. //  MultiView
  51. //
  52. //
  53.  
  54. import UIKit
  55.  
  56. class SecondViewController: UIViewController {
  57.  
  58.     var username : String = "myNickName"
  59.    
  60.     override func viewDidLoad() {
  61.         super.viewDidLoad()
  62.  
  63.         // Do any additional setup after loading the view.
  64.     }
  65.    
  66.  
  67.     /*
  68.     // MARK: - Navigation
  69.  
  70.     // In a storyboard-based application, you will often want to do a little preparation before navigation
  71.     override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  72.         // Get the new view controller using segue.destination.
  73.         // Pass the selected object to the new view controller.
  74.     }
  75.     */
  76.  
  77. }
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement