Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
In Objective-C 2.0, blocks refer to a language construct that supports “closures,” a way of treating code behavior as objects. First introduced to iOS in the 4.x SDK, Apple’s language extension makes it possible to create “anonymous” functionality, a small coding element that works like a method without having to be defined or named as a method.
This allows you to pass that code as parameters, providing an alternative to traditional callbacks. Instead of creating a separate “doStuffAfterTaskHasCompleted” method and using the method selector as a parameter, blocks allow you to pass that same behavior directly into your calls. This has two important benefits.