O'Reilly logo

Objective-C Quick Syntax Reference by Matthew Campbell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required