Skip to content

Instantly share code, notes, and snippets.

@isoiphone
Created October 13, 2015 17:54
Show Gist options
  • Save isoiphone/5370ca2e626d7b3457b3 to your computer and use it in GitHub Desktop.
Save isoiphone/5370ca2e626d7b3457b3 to your computer and use it in GitHub Desktop.
singleton.swift
class FooSingleton {
private static let _sharedInstance = FooSingleton()
class var sharedInstance: FooSingleton {
return _sharedInstance
}
}
@isoiphone
Copy link
Author

Actually, why not just
static let sharedInstance: FooSingleton = FooSingleton()

@JessyCatterwaul
Copy link

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