Sunday, May 27, 2012

IOS -- INTRODUCING BLOCK



1. What is block


     A block is an anonymous inline collection of code that:
  • Has a typed argument list just like a function
  • Has an inferred or declared return type
  • Can capture state from the lexical scope within which it is defined
  • Can optionally modify the state of the lexical scope
  • Can share the potential for modification with other blocks defined within the same lexical scope
  • Can continue to share and modify state defined within the lexical scope (the stack frame) after the lexical scope (the stack frame) has been destroyed

2. Declare and using block








image: ../Art/blocks.jpg








3. __block modifier


   __block variables live in storage that is shared between the lexical scope of the variable and all blocks and   block copies declared or created within the variable’s lexical scope. 





No comments:

Post a Comment