Skip to content

Instantly share code, notes, and snippets.

@Eluss
Created December 11, 2016 21:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Eluss/fc0212d0861c469b9a7e38046d10f633 to your computer and use it in GitHub Desktop.
Save Eluss/fc0212d0861c469b9a7e38046d10f633 to your computer and use it in GitHub Desktop.
class DetailedPersonViewModel: PersonViewModel {
var title: String
var birthday: String
var dateFormatter = DateFormatter()
init(person: Person) {
title = person.firstName + " " + person.lastName
dateFormatter.dateStyle = .short
birthday = dateFormatter.string(from: person.birthday)
}
func doSomeWork() {
// Some complicated logic
}
}
class LuckyPersonViewModel: PersonViewModel {
var title: String
var birthday: String
var dateFormatter = DateFormatter()
init(person: Person) {
title = "Lucky " + person.firstName
dateFormatter.dateStyle = .long
birthday = "Birthday: " + dateFormatter.string(from: person.birthday)
}
func doSomeWork() {
// Any other logic
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment