Learning Objective-C 2.0: A Hands-on Guide to Objective-C for Mac and iOS Developers, Second Edition
by Robert Clair
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access