Defining and Adopting Protocols
Swift is predominantly a protocol-based language. Protocols are also prevalent in Objective-C, frequently used with the delegation design pattern—although there has been a gradual shift from protocol/delegate to block-based usage in recent years. A protocol is simply a contract that defines requirements that the adopting type agrees to implement. This chapter will compare how Objective-C and Swift similarly utilize protocols, pointing out the differences in syntax and examining the broadened usage, new capabilities, and specific caveats of using protocols in Swift.