Created
June 15, 2012 21:47
-
-
Save alaborie/2938856 to your computer and use it in GitHub Desktop.
enumerateObjectsUsingBlock nested in an autorelease pool?
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
NSError *error = nil; | |
void (^block)(NSError **error); | |
block = ^(NSError **blockError) | |
{ | |
NSArray *array = [NSArray arrayWithObject:@"hello"]; | |
[array enumerateObjectsUsingBlock:^(id object, NSUInteger index, BOOL *stop) { | |
if ( blockError != NULL ) | |
{ | |
*blockError = [NSError errorWithDomain:@"domain" code:0 userInfo:nil]; | |
*stop = YES; | |
} | |
}]; | |
}; | |
block(&error); | |
if ( error != nil ) | |
{ | |
[error retain]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you enable the zombies the code will crash at line 19. Apparently the NSError is released when leaving the enumeration block of the array. So the enumeration is probably done within an autorelease block.