O'Reilly logo

Mastering iOS 10 Programming 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

Adding protocols for clarity

We've already seen how protocols can be used to improve code by removing complex inheritance hierarchy. You also know how powerful it is to check for protocol conformance instead of checking whether a certain object is of a certain type. Let's see how we can improve and future-proof the HelloContacts application by adding some protocols.

We will define two protocols for now: one that specifies the requirements for any object that claims to be able to add a special animation to a view, and one that defines what it means to be able to be displayed as a contact.

Defining the view effect animator protocol

The first protocol we will define will be called ViewEffectAnimatorType. This protocol should be applied to any object ...

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