Created
October 13, 2015 17:54
-
-
Save isoiphone/5370ca2e626d7b3457b3 to your computer and use it in GitHub Desktop.
singleton.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FooSingleton { | |
private static let _sharedInstance = FooSingleton() | |
class var sharedInstance: FooSingleton { | |
return _sharedInstance | |
} | |
} |
You don't need explicit typing.
static let sharedInstance = FooSingleton()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually, why not just
static let sharedInstance: FooSingleton = FooSingleton()