Created
June 25, 2013 12:49
-
-
Save Vyazovoy/5858195 to your computer and use it in GitHub Desktop.
Right way to use references inside blocks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSObject *someReferencedObject = [NSObject new]; | |
__typeof(someReferencedObject) __weak weakSomeReferencedObject = someReferencedObject; | |
[someReferencedObject addBlock:^() { | |
__typeof(weakSomeReferencedObject) __strong strongSomeReferencedObject = weakSomeReferencedObject; | |
if (strongSomeReferencedObject) { | |
//do something with strongSomeReferencedObject | |
} else { | |
//appropriate reaction | |
} | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For more information: http://developer.apple.com/library/mac/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html