Blocks
Blocks are an extension to the C language that were first supported in iOS 4. They are similar in concept to a method or function that can be stored in a variable. C provides a similar mechanism for storing functions: function pointers. Blocks go beyond function pointers by storing a copy of the enclosing scope in addition to the block of executable code.
When a block is defined, a copy of the local stack is created and attached to the block. When the block is finally executed, it has access to this copy of the stack. This is very powerful, allowing a block of code and its surrounding state to be passed to a method. This code can be executed at a future point or within a certain context, such as on another thread or in a certain order. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access