Protocol Extensions in Swift

Protocols describe capabilities that types can adopt. Protocol extensions let you provide shared behavior for those types without requiring a common superclass. Defining a Protocol This protocol describes anything that can produce a display title: protocol Displayable { var name: String { get } var subtitle: String? { get } } Every conforming type must provide the required properties. Adding…