- Mastering macOS Programming
- Stuart Grimshaw
- 69字
- 2021-07-02 22:54:36
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.