December 2015
Intermediate to advanced
400 pages
13h 3m
English
Swift supports protocol inheritance. A protocol that inherits from another protocol requires conforming types to provide implementations for all the properties and methods required by both itself and the protocol it inherits from. This is different from class inheritance, which defines a close relationship between the superclass and subclass. Protocol inheritance merely adds any requirements from the parent protocol to the child protocol. For example, modify TabularDataSource so that it inherits from the CustomStringConvertible protocol.
Listing 19.12 Making TabularDataSource inherit from CustomStringConvertible
protocol TabularDataSource: CustomStringConvertible { var numberOfRows: Int { get } var numberOfColumns: ...Read now
Unlock full access