O'Reilly logo

iOS Programming: The Big Nerd Ranch Guide by Joe Conway, Aaron Hillegass

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

27Blocks

In this chapter, you will learn about a C and Objective-C language feature called blocks. A block is a set of instructions. It is an object, but it is called like a function. Blocks provide conveniences for a programmer and performance boosts for applications. If you are familiar with other high-level languages, you may know blocks as closures or anonymous functions. This chapter will introduce blocks and their syntax. In the next chapter, you will put blocks to use in your Nerdfeed application.

Blocks and Block Syntax

In the C programming language, we separate code into functions. A function is defined as its own entity...

i​n​t​ ​a​d​d​e​r​(​i​n​t​ ​a​,​ ​i​n​t​ ​b​)​
{​
 ​ ​ ​ ​r​e​t​u​r​n​ ​a​ ​+​ ​b​;​
}​

and can be called anywhere. ...

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