I want to get the ViewController variable From AppDelegate, I tried :
//1.
print(ViewController().strName)
//2.
let vc = ViewController()
print(vc.strName)
//3.
let vc = UIApplication.shared.keyWindow!.rootViewController as! ViewController
print(vc.strName)
All not working, the print value is empty...
The code in ViewController:
var strName : String = ""
override func viewDidLoad() {
strName = "Tom"
}