7.6 · UITableView, still asked and still everywhere
Collection views with list layouts are the modern choice, but table views are in nearly every existing codebase, and their rules for data consistency are the ones interviewers test.
Mental model. A table view never owns your data. It asks you for counts and cells, and trusts that your answers are consistent with the changes you tell it about.
The table view
Data source rules, sizing, and updates that crash.
- How does a UITableView get its rows, and why do batch updates crash when the data and the update disagree?
A table view asks its data source for the number of sections and rows and for a cell per index path, and asks its delegate about behaviour (selection, row… - Table view or collection view: which do you choose for new code?
For new screens, prefer a collection view with a list configuration (UICollectionLayoutListConfiguration). It gives you the table look (separators, swipe…
More in UIKit
- 7.1 · Hit testing, the responder chain and gesture recognisers
- 7.2 · UIView and CALayer, frame, bounds and center
- 7.3 · View controller lifecycle, containment, presentation and transitions
- 7.4 · Navigation, tab, split and page controllers
- 7.5 · Compositional layout, diffable data sources, cell reuse and prefetching
- 7.7 · Trait collections, size classes, safe area, keyboard and appearance
- 7.8 · Keyboard shortcuts, pointer, Apple Pencil and multitasking
- 7.9 · Hosting SwiftUI in UIKit and UIKit in SwiftUI
- 7.10 · Initialisers, stack views, scroll views and modern buttons
- 7.11 · Layout passes, retain cycles and menus
- 7.12 · Refreshing diffable cells, outlines and carousel layouts
- 7.13 · View-tree exercises and long navigation stacks