Skip to content

Instantly share code, notes, and snippets.

@Abhishek9634
Created August 16, 2018 21:28
Show Gist options
  • Save Abhishek9634/dc1f136a36b0900896cb01ceeaf004b0 to your computer and use it in GitHub Desktop.
Save Abhishek9634/dc1f136a36b0900896cb01ceeaf004b0 to your computer and use it in GitHub Desktop.
//
// BeerTableViewCell.swift
// BeerCrafts
//
// Created by Abhishek on 29/06/18.
// Copyright © 2018 Abhishek. All rights reserved.
//
import UIKit
protocol BeerTableViewCellDelegate: class {
func didTapAddButton(cell: BeerTableViewCell)
}
class BeerTableViewCell: TableViewCell {
@IBOutlet weak var themeLabel: UILabel!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var alcoholContentLabel: UILabel!
override func awakeFromNib() {
super.awakeFromNib()
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
}
override func configure(_ item: Any?) {
guard let model = item as? BeerCellModel else { return }
self.themeLabel.text = model.beer.style
self.nameLabel.text = model.beer.name
self.alcoholContentLabel.text = model.beer.abv
}
@IBAction func addAction(_ sender: Any) {
(self.delegate as? BeerTableViewCellDelegate)?.didTapAddButton(cell: self)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment