Last active
August 17, 2022 05:55
-
-
Save hsleedevelop/46235610fd9e4259374b5186279e0f83 to your computer and use it in GitHub Desktop.
TableView Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typealias DataSource = UITableViewDiffableDataSource<Int, String> | |
typealias SnapShot = NSDiffableDataSourceSnapshot<Int, String> | |
private var dataSource: DataSource! | |
@IBOutlet weak var tableView: UITableView! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view. | |
setupTableView() | |
setupDataSource() | |
fetchData() | |
} | |
/// Setup table view. | |
private func setupTableView() { | |
tableView.backgroundColor = .clear | |
tableView.separatorStyle = .none | |
tableView.rowHeight = UITableView.automaticDimension | |
tableView.allowsSelection = true | |
tableView.tableFooterView = .init(frame: .init(x: 0, y: 0, width: 0, height: 50)) | |
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "CellIdentifier") | |
} | |
private func setupDataSource() { | |
dataSource = DataSource(tableView: tableView, cellProvider: { tableView, indexPath, menuCase in | |
let cell = tableView.dequeueReusableCell(withIdentifier: "CellIdentifier", for: indexPath) | |
return cell | |
}) | |
} | |
private func fetchData() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment