One of the hardest programming concepts for me to understand in the past few weeks as I’m learning iOS development was, you guessed it, Delegates! So I’d like to share how I’ve come to think of them… using a CoffeeShop analogy. So here is the story:

You wake up this morning, and you want coffee. But alas, you can’t make coffee yourself. So you get up, get dressed and go to a coffee shop. You know that every coffee shop conforms to a specific protocol. You walk in and say “makeMeMyCoffee”, and they make you your coffee. In other words, you’re delegating coffee making to a coffee shop:

Each coffee shop, whether it’s Starbucks or Dunkin’ Donuts or your neighborhood mom and pop coffee shop, conform to the CoffeeShop protocol. When you walk in and say “makeMeMyCoffee” they know to make you coffee. Let’s say this morning you’re feeling like Starbucks: