mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-24 18:11:38 +00:00
Merge pull request #3100 from chrisdusovic/master
[objective-c/en] Add missing block referred to in comment
This commit is contained in:
commit
44f9834b2c
@ -731,7 +731,10 @@ if ([myClass conformsToProtocol:@protocol(CarUtilities)]) {
|
|||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
// Blocks are statements of code, just like a function, that are able to be used as data.
|
// Blocks are statements of code, just like a function, that are able to be used as data.
|
||||||
// Below is a simple block with an integer argument that returns the argument plus 4.
|
// Below is a simple block with an integer argument that returns the argument plus 4.
|
||||||
int (^addUp)(int n); // Declare a variable to store the block.
|
^(int n) {
|
||||||
|
return n + 4;
|
||||||
|
}
|
||||||
|
int (^addUp)(int n); // Declare a variable to store a block.
|
||||||
void (^noParameterBlockVar)(void); // Example variable declaration of block with no arguments.
|
void (^noParameterBlockVar)(void); // Example variable declaration of block with no arguments.
|
||||||
// Blocks have access to variables in the same scope. But the variables are readonly and the
|
// Blocks have access to variables in the same scope. But the variables are readonly and the
|
||||||
// value passed to the block is the value of the variable when the block is created.
|
// value passed to the block is the value of the variable when the block is created.
|
||||||
|
Loading…
Reference in New Issue
Block a user