CHAPTER 20

image

Blocks

Blocks Defined

Blocks are a way to define a block of code that you will use at a later time. Blocks are a lot like methods or functions in that they can take parameters and return a value. Sometimes people refer to blocks as anonymous functions because they are functions that aren’t attached to an entity.

One thing that sets blocks apart is that they are coded in the same scope as the rest of your program so you can add a block without a class definition. Blocks have some other properties that make them very useful. While blocks don’t need to be attached to objects, blocks can be treated as objects. This means that you can code ...

Get Objective-C Quick Syntax Reference 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.