Skip to content

Instantly share code, notes, and snippets.

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 AviTsadok/24fce4d05208588075edcaa5ec303ad1 to your computer and use it in GitHub Desktop.
Save AviTsadok/24fce4d05208588075edcaa5ec303ad1 to your computer and use it in GitHub Desktop.
DiffableDataSource creating data source
import UIKit
class ViewController: UIViewController {
var datasource : UITableViewDiffableDataSource<Section, Item>!
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.register(UINib(nibName: "CustomTableViewCell", bundle: nil), forCellReuseIdentifier: "CustomTableViewCell")
self.datasource = UITableViewDiffableDataSource(tableView: tableView, cellProvider: { (tableView, indexPath, item) -> UITableViewCell? in
let cell = tableView.dequeueReusableCell(withIdentifier: "CustomTableViewCell") as! CustomTableViewCell
cell.customLabel.text = item.data
return cell
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment