Understanding How to Apply UItableview and UITableViewDataSource Methods Based on Apple's Documentation

78 Views Asked by At

I'm currently going through a tutorial on UITableView. While learning I'm attempting to understand how the UITableView should be constructed by following Apple's documentation and its programming guides. In the tutorial, the developer places the dequeueReusableCell(withIdentifier:) method inside of the tableView(_:cellForRowAt:) method which belongs to the datasource. As a newcomer after reading Apple's references and guides, I would not have guessed that the dequeueReusableCell(withIdentifier:) method goes inside of the tableView(_:cellForRowAt:) method. As a developer, how do you pick up on subtle things like this? Is it because the tableView(_:cellForRowAt:) method returns a UITableViewCell and may be the best place to do UITableViewCell configurations?

I'd like to gain a better understanding of Apple's references for future projects, thank you in advance for any comments or answers.

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

        let cell = tableView.dequeueReusableCell(withIdentifier: "ItemCell", for: indexPath)

        return cell

}
0

There are 0 best solutions below