Created
February 3, 2012 00:23
-
-
Save bjhomer/1726708 to your computer and use it in GitHub Desktop.
Blocks are copied often
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
#import <Foundation/Foundation.h> | |
int main (int argc, const char * argv[]) | |
{ | |
@autoreleasepool { | |
__block int x; | |
NSLog(@"Address of x outside of block: %p", &x); | |
^{ | |
NSLog(@"Address of x in non-assigned block: %p", &x); | |
}(); | |
void (^b)(void) = ^{ | |
NSLog(@"Address of x in assigned block: %p", &x); | |
}; | |
b(); | |
} | |
return 0; | |
} |
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
2012-02-02 17:23:19.010 blockcopying[39728:707] Address of x outside of block: 0x7fff5fbff918 | |
2012-02-02 17:23:19.012 blockcopying[39728:707] Address of x in non-assigned block: 0x7fff5fbff918 | |
2012-02-02 17:23:19.013 blockcopying[39728:707] Address of x in assigned block: 0x103000048 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment