Skip to content

Instantly share code, notes, and snippets.

@Eluss
Last active December 11, 2016 20:59
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/0446c0be1eb12a0fc972a15eaebd31be to your computer and use it in GitHub Desktop.
Save Eluss/0446c0be1eb12a0fc972a15eaebd31be to your computer and use it in GitHub Desktop.
protocol PersonViewModel {
var title: String {get}
var birthday: String {get}
func doSomeWork()
}
class PersonView: UIView {
private var titleLabel: UILabel!
private var birthdayLabel: UILabel!
private var workButton: UIButton!
private var viewModel: BobViewModel
init(viewModel: PersonViewModel) {
self.viewModel = viewModel
super.init(frame: .zero)
setupView()
}
private func setupView() {
titleLabel.text = viewModel.title
birthdayLabel.text = viewModel.birthday
}
func workButtonTapped() {
viewModel.doSomeWork()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment