Creating and implementing a custom collection view cell

When you implemented the table view cell in the previous chapter, you designed a custom cell. This cell was a special kind of view that the table view reused for every contact that was visible on the screen. A collection view uses cells in a very similar way, but you can't use table view cells in a collection view and vice versa. However, both cells share a lot of functionality. For instance, they both have a prepareForReuse and an awakeFromNib method. This is why you haven't removed any code for the table view cell earlier; you can reuse the implementation code.

When you dragged the collection view onto the storyboard, it came with a default cell. This cell is a lot more flexible than ...

Get Mastering iOS 12 Programming - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.