Skip to content

Instantly share code, notes, and snippets.

@serhatsezer
Last active August 11, 2017 13:54
Show Gist options
  • Save serhatsezer/4d02dae2641e19346907d6c68cc65fd0 to your computer and use it in GitHub Desktop.
Save serhatsezer/4d02dae2641e19346907d6c68cc65fd0 to your computer and use it in GitHub Desktop.
// Here we are creating representables for to take advantage of all representables.
typealias Representables = protocol<TextPresentable, SwitchPresentable, ImagePresentable>
class ProductListCell: UITableViewCell {
@IBOutlet private weak var label: UILabel!
@IBOutlet private weak var switch: UISwitch!
@IBOutlet private weak var imageView: UIImageView!
func configure(presenter: Representables) {
label.text = presenter.text
switch.on = presenter.switchOn
imageView.image = UIImage(named: presenter.imageName)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment