I am just reading the code from the Udacity training material. The teacher makes an instance variable sharedInstancec struct, which is wrapped inclass function
Why can't we just do it static var?
class BugFactory() {
class func sharedInstance() -> BugFactory {
struct Singleton {
static var sharedInstance = BugFactory()
}
return Singleton.sharedInstance
}
}
Why this is not recommended:
class BugFactory() {
static var sharedInstance = BugFactory()
}
source
share