From the course: Swift 5: Protocol-Oriented Programming
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Introducing the protocol
From the course: Swift 5: Protocol-Oriented Programming
Introducing the protocol
- [Instructor] Protocols stand at the core of POP. They model abstraction by describing what the conforming types shall implement. Protocol names must begin with a capital letter. Apple has clear recommendations regarding protocol naming. Protocols that describe what something is should read as nouns. For example, collection, UITableViewDataSource, or UITextFieldDelegate. Protocols that describe a capability should be named using the suffixes able, ible, or ing. Such a Codable, CustomStringConvertible, and NSCoding. Let's get started exploring the protocol syntax. Open up Xcode and create a playground called protocols. Let's make it full screen and I'm going to remove the generated code except the import will need Foundation. All right, we declare a protocol called Taggable. I'm using the protocol keyword and let's call it Taggable. The protocol definition, that is the method and the calculated property requirements go…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
What is protocol-oriented programming?2m 15s
-
(Locked)
Introducing the protocol5m 18s
-
(Locked)
Adopting protocols1m 54s
-
(Locked)
Conforming to protocols via extensions3m 38s
-
(Locked)
Understanding polymorphism4m
-
(Locked)
Protocol inheritance3m 41s
-
(Locked)
Adopting multiple protocols5m 50s
-
(Locked)
Protocol extensions3m 23s
-
(Locked)
Challenge: Removing tight coupling3m 13s
-
(Locked)
Solution: Removing tight coupling8m 33s
-
-
-
-
-