上QQ阅读APP看书,第一时间看更新
Declaring method requirements
Let us start by declaring a simple protocol and having a look at what it all means:
protocol Talkative
{
func sayHi()
}
The Talkative protocol says that any type declaring itself to conform to the protocol will implement its own version of the sayHi function.
That's all it does, and yet simple though it is, this idea turns out to be immensely powerful. Keep reading.