[ad_1]
I’ve a TableView that’s being populated with knowledge loaded from Firestore:
extension ViewController: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection part: Int) -> Int {
return dataLoadedFromModel.rely
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CustomPlanCell", for: indexPath) as! CustomCell
let dataInRow = dataLoadedFromModel[indexPath.row]
cell.displayData(knowledge: dataInRow, indexPathRow: indexPath.row)
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let dataInRow = dataLoadedFromModel[indexPath.row]
}
}
I’ve carried out the UITableViewDataSourcePrefetching protocol like the next:
override func viewDidLoad() {
tremendous.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
tableView.prefetchDataSource = self
}
extension ViewController: UITableViewDataSourcePrefetching {
func tableView(_ tableView: UITableView, prefetchRowsAt indexPaths: [IndexPath]) {
for indexPath in indexPaths {
let dataInRow = dataLoadedFromModel[indexPath.row]
}
}
}
Is it sufficient that I known as let dataInRow = knowledge[indexPath.row] (which assigns knowledge to the indexPath) in each my cellForRowAt and prefetchRowsAt strategies? Word: dataLoadedFromModel is being loaded efficiently from my mannequin elsewhere within the code.
It appears like my knowledge is loading quicker as I scroll by the Desk View, nevertheless it’s powerful to inform. Is there the rest I am lacking from implementing the UITableViewDataSourcePrefetching protocol? What can I do to verify I carried out it correctly?
[ad_2]
