I am having trouble wrapping my head fully around delegates. I find that they are a bit difficult to grasp and was wondering if anyone had resources they used to help understand them?
How do you feel about protocols? There a new video on them:
Delegates are historically the most common use of protocols in Apple development.
The one thing that helped me most with the concept of delegates is not to think of it as a noun but a verb.
I delegate some other object to perform this task…
Implying there is a task to be done but the implementation of the task is not this object’s concern. It matters that it happen, not how it happens. A common example is the UITableViewDelegate. When a row gets selected it does not matter to the table view what happens, it simply reports that it happened. Nothing can happen, or the whole app could terminate, but after providing some feedback and making that delegate function call that’s all the table view knows.
It is certainly important to understand the basics of how protocols are defined and what they mean too, a delegate is just a special kind of protocol.