User Tools

Site Tools


ios-labs-s14:advanced-blocks

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Last revision Both sides next revision
ios-labs-s14:advanced-blocks [2014/03/01 11:38]
mbarboi created
ios-labs-s14:advanced-blocks [2014/03/01 11:51]
mbarboi
Line 33: Line 33:
 </​code>​ </​code>​
  
 +Note the curly braces wrapping the code, followed the the square bracket closing the method call. 
  
 +Blocks introduce a number of scope issues:
 +  -Local and instance variables cannot be referred to in a block unless declared with the "​__block"​ prefix
 +  -Properties can be used using the "​self.property"​
 +  -"​self"​ can be used in a block, but doing so **captures self**. This is potentially dangerous
 +
 +Best practice is **not** to access local, instance, or public variables of a class within a block literal defined in that class.
ios-labs-s14/advanced-blocks.txt ยท Last modified: 2015/10/30 11:54 by mbarboi