上QQ阅读APP看书,第一时间看更新
Getting ready
The syntax of protocol goes like this:
protocol ProtocolName{ // List of properties and methods goes here.... }
The keyword protocol followed by the protocol name and curly braces are the building blocks of any protocol you need to write. Classes, structures, or enumeration can then conform to it like this:
class SampleClass: ProtocolName{ }
After class name, you type colon and the super class name that this class extend from if any, followed by a list of protocols that you want to conform to with a comma separation.