April 2026
Intermediate
683 pages
25h 29m
English
In Swift, protocol-supporting data types are free to implement multiple protocols. So long as all imposed properties and functions are implemented, there is no restriction against that. Figure 10.10 illustrates a sample architecture in which different classes implement different sets of protocols.
Figure 10.10 Sample Architecture for Multiprotocol Implementations
The protocol implementation plan is summarized in Table 10.2. As seen here, GasCar and ElectricCar both implement multiple protocols rather than a single one.
|
Class |
Implemented Protocols |
Supported Functions |
|---|---|---|
|
Bike |
Vehicle |
Read now
Unlock full access