Last active
August 1, 2019 07:16
-
-
Save piyushdec/4b3ff3d3a2295f24a12dc6dbc5328d60 to your computer and use it in GitHub Desktop.
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
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