Last active
March 23, 2018 02:48
-
-
Save alexvbush/2a587bf3d5a660e1239a7206be3d1659 to your computer and use it in GitHub Desktop.
This file contains 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
import Foundation | |
struct User { | |
let firstName: String | |
let lastName: String | |
func fullName() -> String { | |
return "\(firstName) \(lastName)" | |
} | |
} | |
class YourViewControllerOrSomeOtherPlace { | |
var user: User? | |
func viewDidLoadOrSomeOtherMethod() { | |
if let user = user { | |
print("rendering UI for the user since we clearly have one") | |
print("user's full name is: \(user.fullName())") | |
} else { | |
print("rendering UI for no-user case") | |
print("Hi no-user, you should really sign in!") | |
} | |
} | |
} | |
let aVCWithAUser = YourViewControllerOrSomeOtherPlace() | |
aVCWithAUser.user = User(firstName: "Joe", lastName: "Dow") | |
aVCWithAUser.viewDidLoadOrSomeOtherMethod() | |
print("=================") | |
let aVCWithNoUser = YourViewControllerOrSomeOtherPlace() | |
aVCWithNoUser.viewDidLoadOrSomeOtherMethod() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment