A class can conform to:
Only one protocol.
One or more protocols.
A maximum of two protocols.
When a class conforms to a protocol:
It cannot inherit from a class.
It can inherit from an abstract class.
It can also inherit from a class.
A protocol:
Can inherit from another protocol.
Can inherit from a class.
Cannot inherit from another protocol.
A protocol:
Is a type.
Is a method.
Is the base class for other classes.
When we specify a protocol as the type for an argument:
We can use any type method that conforms to the specified protocol as an argument.
We can use any protocol that conforms to the specified protocol as an argument.
We can use any instance of a class that conforms to the specified protocol as an argument.
You're reading from Object???Oriented Programming with Swift 2
The rest of the page is locked
You have been reading a chapter from
Object???Oriented Programming with Swift 2Published in: Jan 2016Publisher: ISBN-13: 9781785885693
© 2016 Packt Publishing Limited All Rights Reserved