Protocols and Delegates – a really simple example

Thanks to John Muchow for this post explaining how to use protocols and delegates so that one object can notify other objects when an event happens in iOS.

There’s a great comment on this page by a “Grant” which encapsulates what we’re trying to do in a nutshell:

“The best way to describe what it does is a “call back”. i.e. Object A creates Object B and tasks it to do something. Object A would like to know when Object B is done, but rather than it keep asking Object B at set intervals: “Are you done yet? Are you done yet? Are you done yet? etc…” (polling), it instead just says to Object B, “This is a reference to me, use this reference to let me know when you’re done”.