What is UITableView and how do you implement it?
Answer
UITableView displays a list of items in a single column with optional sections. It uses a data source and delegate pattern. It's one of the most commonly used UIKit components. Implementation steps: (1) Add UITableView to view hierarchy; (2) Set dataSource and delegate; (3) Register cell class or nib; (4) Implement required dataSource methods: class UsersViewController: UIViewController, UITableViewDataSource, UITableViewDelegate { var users: [User] = [] let tableView = UITableView() override func viewDidLoad() { super.viewDidLoad() tableView.dataSource = self tableView.delegate = self tableView.register(UITableViewCell.self, forCellReuseIdentifier: "Cell") view.addSubview(tableView) fetchUsers() } // Required: func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return users.count } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) let user = users[indexPath.row] cell.textLabel?.text = user.name cell.detailTextLabel?.text = user.email return cell } // Optional: func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: true) let user = users[indexPath.row] navigateToDetail(user) } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 60 } }. Cell reuse (dequeueReusableCell): the key to UITableView's performance — only creates enough cells to fill the screen, reuses off-screen cells as new ones come into view. Custom cells: subclass UITableViewCell, design in Interface Builder or code. Sections: implement numberOfSections and titleForHeaderInSection.