Swift: how to distinguish a global variable from a class member?
1 answer
The scope of the "global" variable title
is a module defined by your Xcode project. By default, its name is the same as your target name. So, if your code is in a project that creates an app called MyApp
, you can do this:
var title = "Hello"
class ThisClass {
var title = ""
func aMethod () {
self.title = MyApp.title
}
}
+6
source to share