Created
June 25, 2016 23:41
-
-
Save sashalondon/79c08be531a24111492b3184efa9380f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global.swift: | |
class Main { | |
var name:String | |
init(name:String) { | |
self.name = name | |
} | |
} | |
var mainInstance = Main(name:"My Global Class") | |
You can now access this mainInstance from all your view controllers and the name will always be "My Global Class". Example from a viewController: | |
viewController: | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
println("global class is " + mainInstance.name) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment