Chapter 14. Iterator

Every time you buy a soda from a soda machine, you pop some coins in it, select the type of soda you want, and then it is delivered in the delivery tray.

Obviously, there is more than one bottle stored inside the soda machine. We consumers just won't know how those bottles are organized in the big tin box and how they are dispensed unless we crack the machine open to see what's inside. Otherwise, every time we buy a bottle of soda, we can only expect the machine to dispense the next bottle. The dispenser software running in the machine knows all the details about which bottle should next be dispensed among the whole collection of them available.

There are at least two main parts in a soda machine that do the job:

  • An internal ...

Get Pro Objective-C Design Patterns for iOS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.