Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sashalondon/79c08be531a24111492b3184efa9380f to your computer and use it in GitHub Desktop.
Save sashalondon/79c08be531a24111492b3184efa9380f to your computer and use it in GitHub Desktop.
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