Skip to content

Instantly share code, notes, and snippets.

@loganwright
Created October 9, 2015 03:13
Show Gist options
  • Save loganwright/3908e56bb0962d65a5fc to your computer and use it in GitHub Desktop.
Save loganwright/3908e56bb0962d65a5fc to your computer and use it in GitHub Desktop.
TableViewCell Binding Data
protocol Configurable {
func configure<T : TableViewCellConvertible>(model: T)
}
protocol TableViewCellConvertible {
typealias CellType : UITableViewCell, Configurable
var identifier: String { get }
}
extension TableViewCellConvertible {
func dequeueCellFromTableView(tableView: UITableView, forIndexPath indexPath: NSIndexPath) -> CellType {
let cell = tableView.dequeueReusableCellWithIdentifier(identifier, forIndexPath: indexPath) as! CellType
cell.configure(self)
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment