Singleton: Difference between revisions

(Lingo added)
Line 1,886:
SharedInstance ifNil: [SharedInstance := self basicNew initialize].
^ SharedInstance
</lang>
 
=={{header|Swift}}==
<lang swift>
 
class SingletonClass {
 
static let sharedInstance = SingletonClass()
 
///Override the init method and make it private
private override init(){
// User can do additional manipulations here.
}
}
// Usage
let sharedObject = SingletonClass.sharedInstance
</lang>