Vincia Tanqling Vincia Tanqling - 3 months ago 12
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

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
Comments