Skip to content

Instantly share code, notes, and snippets.

@piyushdec
Last active August 1, 2019 07:16
Show Gist options
  • Save piyushdec/4b3ff3d3a2295f24a12dc6dbc5328d60 to your computer and use it in GitHub Desktop.
Save piyushdec/4b3ff3d3a2295f24a12dc6dbc5328d60 to your computer and use it in GitHub Desktop.
struct User {
let name: String
}
class UserController {
static let shared = UserController()
var currentUser: User?
private init() {
//don't forget to make this private
}
func signout() {
print("singing out current session")
}
}
class HomeViewController: UIViewController {
private lazy var name = UILabel()
override func viewDidLoad() {
super.viewDidLoad()
name.text = UserController.shared.currentUser?.name
}
private func handleSignOutButtonTap() {
UserController.shared.signout()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment