toiavalle
toiavalle

Reputation: 434

How to use variables from different class in swift?

I want to access a variable from my AppDelegate Class in my other class

class AppDelegate: NSObject, NSApplicationDelegate

class Other: NSView

I tried AppDelegate.variable but it doesn't work

Upvotes: 0

Views: 57

Answers (1)

pbush25
pbush25

Reputation: 5258

You need to do this: let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate and then you can access its member variables.

Upvotes: 2

Related Questions