When to use a protocol?


#1

How do you know when you need (specifically for controllers) to use a protocol? I understand the purpose of protocols, I’m just not understand why & when to use them.

What threw me off specifically was the NSTableDataSource examples. Quote from page 104, “The data source must conform to the NStableDataSource informal protocol.” What’s the reasoning behind this and how would someone know this when creating their own applications? Is there a page in the documentation that explains this?

Thanks in advance. Really loving this book by the way (cocoa programming is getting more enjoyable the deeper I get into it :smiley: )


#2

It all explained in NSTableView Class Reference.
For example:

And


#3

Appreciate it! I’ll be checking the documentation more often :wink: