Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
As we’ve learned, a Block literal looks the same as a function definition except it has no name and it has the “^” symbol. For the C function, the address of the function can be assigned to a variable of the function pointer type.
int func(int count)
{
return count + 1;
}
int (*funcptr)(int) = &func;
In the example, the address of function “func” is assigned to a variable “funcptr”.
In a similar manner, a Block literal can be assigned to a Block-type variable, which means that when a Block literal is in source code, a value is generated. The value can be assigned to a variable of the Block type. In Blocks, the generated value is called Block as well. “Block” is used both for a Block literal itself in a source code and the value generated from the Block literal. Next, let’s see how to declare Block-type variables.