17. Blocks
Blocks provide a way to package up some executable code and a context (various variables) as a single entity so they can be handed off for execution at a later time or on a different thread. In other languages, blocks or similar constructs are sometimes called closures or anonymous functions. Blocks are an Apple-supplied extension to C, Objective-C 2.0, and C++. Apple has submitted blocks to the C standards working group as a proposed extension to C. Blocks are available on Mac OS X 10.6 or later and iOS 4.0 or later.
Note
You can use blocks on iOS 2.2+ and on Mac OS X Leopard (10.5) if you install Plausible Blocks (PLBlocks). Plausible Blocks, a reverse-engineered port from Apple-released open-source Darwin OS code, provides the ...
Get Learning Objective-C 2.0: A Hands-on Guide to Objective-C for Mac and iOS Developers, Second 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.