O'Reilly logo

Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming by Erica Sadun, Rod Strougo, Maurice Sharp

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

Block Basics

In many ways, a block is like an anonymous function: It can take arguments, it can return a value, and a symbol can be used to call a block. But blocks are much more than this. Using them is a way to pass inline “functions” as method arguments. And most powerfully of all, blocks have access to all the variables that are in scope at the time they are defined. Or put another way, a block is a closure that has access to any variable the creating method can access at the point when the block is defined.

Before you can use blocks, you need to know how to declare, use, and write them.

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