O'Reilly logo

Mastering iOS 11 Programming - Second Edition by Donny Wals

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining a contact display protocol

Many apps display lists of contents that are almost the same, but not quite. Imagine displaying a list of contacts: a placeholder for a contact that can be tapped to add a new contact and other cells that could suggest people you may know. Each of these three cells in the collection view could look the same, yet the underlying models can be almost completely different.

You can achieve this with a simple protocol that defines what it means to be displayed in a certain way. It's a perfect example of the situation where you're more interested in an object's capabilities than its concrete type. To determine what it means to be displayed in the contact overview, we should look inside ViewController.swift. The ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required