Skip to content

Instantly share code, notes, and snippets.

@mimthath4
Last active January 29, 2020 04:39
Show Gist options
  • Save mimthath4/29f110d08448e3f75b8d32d58ee284f7 to your computer and use it in GitHub Desktop.
Save mimthath4/29f110d08448e3f75b8d32d58ee284f7 to your computer and use it in GitHub Desktop.
import UIKit
class PostsViewController: MITableViewController {
init(posts: [Post]) {
super.init(style: .plain)
sections.append(SectionItem(id: "Post", header: nil, items: posts))
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func registerCells() {
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "postCell")
}
}
extension Post: RowItem {
func getCell(at indexPath: IndexPath, of tableView: UITableView) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "postCell", for: indexPath)
cell.textLabel?.text = self.title
return cell
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment