I first learned how to implement the Singleton pattern in Swift in this book, Pro Design Patterns in Swift .
The way I started implementing the Singleton template is in the following example:
class Singleton { class var sharedInstance: Singleton { struct Wrapper { static let singleton = Singleton() } return Wrapper.singleton } private init() { } }
But then I found this implementation while reading Cocoa Design Patterns
class Singleton { static let sharedInstance = Singleton() private init() { } }
So my question is, what is the difference between the two implementations?
source share