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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.