Chapter 7Doing Two Things at Once with Closures

We started the last chapter with the example of a hypothetical household robot, who would answer the phone for us. We dealt with the problem of prank callers that never respond to “Hello” by batching together all of our instructions for how to handle the greeting until after the caller responds. That leaves the robot free to do other tasks in the meantime. Now let’s think about how that would work.

Some tasks will require the robot’s limbs, some need its eyesight, and others its voice and hearing. If we’re careful about how we divvy up tasks, the robot can do several things at once: we can prepare dinner while talking on the phone, and our robot should be able to as well.

So let’s imagine we have ...

Get iOS 8 SDK Development, 2nd Edition 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.