A good way to let the Swift compiler help you build a rock-solid UICollectionView or UITableView is to manage their layout structure through an enum. More information and sample code: https://goto.project-a.com/swift-enums-for-solid-uicollectionview-uitableview/ These slides accompanied my talk at http://swift.berlin/