Pick the fix
You need a grid on iPad, a list on iPhone, and animated updates without crashes from mismatched counts. Which approach?
Hint 1 of 1
Which option separates data from layout?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A UICollectionView with a compositional layout and a UICollectionViewDiffableDataSource
Correct. One view adapts its layout, and snapshots animate changes safely.
Why not the others?
- B UITableView with reloadData(). No grid, and no animations.
- C performBatchUpdates with hand-computed index paths. That is exactly where 'invalid number of items' crashes come from.
- D UIStackViews inside a UIScrollView. No cell reuse, so long lists use too much memory.