Im just starting with Swift and i can get past this problem i dont know how to run the function inside the ViewController2 from ViewController.
import UIKit
class Main: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
@IBAction func onButtonPressed(_ sender: Any) {
performSegue(withIdentifier: "newSegue", sender: self)
}
}
class ViewController: UIViewController {
let SecondViewController = ViewController2()
override func viewDidLoad() {
super.viewDidLoad()
SecondViewController.changeText()
// Do any additional setup after loading the view, typically from a nib.
}
}
class ViewController2: UIViewController {
@IBOutlet weak var label1: UILabel!
@IBOutlet weak var label2: UILabel!
@IBOutlet weak var label3: UILabel!
@IBOutlet weak var label4: UILabel!
@IBOutlet weak var label5: UILabel!
@IBOutlet weak var label6: UILabel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
func changeText() {
label1.text = "hi"
label2.text = "how"
label3.text = "are"
label4.text = "you"
label5.text = "doing"
label6.text = "!"
}
}