Chapter 13. Protocols, Extensions, and Generics

Protocols should be a familiar sight to any Objective-C developer. They are used throughout the Apple frameworks to define behaviors (in the form of properties and methods) that classes should conform to. Although extensions may sound new, they already exist in Objective-C as categories and can be used to provide extra functionality to existing classes. Swift protocols and extensions differ from their Objective-C counterparts in that they can be used with structures and enumerations as well as classes.

Generics are a completely new technology introduced by Swift. Their purpose is to allow a function or a type to be created in such a way that the type it acts upon does not need to be specified at ...

Get Swift Translation Guide for Objective-C Users: Develop and Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.