Deep Dive into all aspects of Block, deep dive into block
Content outline:
1. Blocks Summary
2. Blocks Mode
3. Block essence (key points for interviews)
1. Blocks Summary
What is Blocks: Blocks is an extension function of C language. It can be expressed in one sentence as an anonymous function with local variables (some local variables are also called automatic variables. This function is called block. (Note that Blocks is a function and block is a function)
1-1. About "anonymous functions"
Anonymous functions: functions without names are anonymous functions. (However, the C language standard does not allow such a function .)
For example, in the source code below: if you do not use the name of the function to assign a value to the function pointer, the address of the function cannot be obtained:
However, with Block, the source code can use anonymous functions, that is, functions without names.
1-2. About "local variables (in some documents, local variables are also called automatic variables )"
To help you better understand this "with local variables (some local variables are also called automatic variables )",The process of callback for common functions
AndBlock Function callback Process
In this way, readers can better understand the significance of the block "with local variables (some local variables are also called automatic variables)" and the features of the block.
(It can be a feature by comparing the differences