Vincia Tanqling Vincia Tanqling - 1 year ago 78
Swift Question

How to declare viewcontroller globally

let VC1 = self.storyboard!.instantiateViewControllerWithIdentifier("loadingViewController") as! loadingViewController


How to declare VC1 globally so it can use it different function

Answer Source

Create it first like this (globally):

 let VC1 = LoadingViewController()

Then go to your view controller and add this in viewDidLoad:

VC1 = self.storyboard!.instantiateViewControllerWithIdentifier("loadingViewController") as! loadingViewController