Chapter 7. Blocks and Closures

Blocks are a relatively new addition to iOS and OS X development, and although Apple delivered them as part of Objective-C, they are actually an enhancement to the C language itself. This comes through in their syntax: It is confusing, hard to remember, and unintuitive. Any syntax that inspires developers to create websites like Gosh Darn Block Syntax (http://goshdarnblocksyntax.com) as a blocks cheat sheet cannot be considered to be particularly user friendly.

Despite this, blocks are here to stay, and they’re taking over our APIs. Apple took the time to improve the syntax of blocks, and to provide numerous syntactical optimizations that simplify their usage in many common patterns. They also decided to rename ...

Get Swift Translation Guide for Objective-C Users: Develop and Design 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.