8. Protocols
Protocols are at the heart of the iOS architecture; they are first-class paradigms, right up there with classes and structs. They hold a special place because they are the backbone of design patterns such as delegates. Delegates are heavily used in iOS for notifying the programmer when application, UI, and other events happen. You can use a delegate to send a message to everyone who conforms to that protocol. When you use a protocol and all of its offerings, it is called conforming to the protocol.
Protocols themselves don’t have any implementation at all—that is, you don’t really write code in protocols that does stuff. You can use protocols as a checklist to say, “I need you to write the following methods if you want this thing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access