I wish to set an NSError pointer from within a block in a project using automatic reference counting. What follows is a simplified version of my code:
- (BOO
Note: As of 2020, this workaround is no longer necessary.
Try this:
// ...
__block NSError *blockError = nil;
[items enumerateObjectsUsingBlock:^(id item, NSUInteger idx, BOOL *stop) {
NSError *localError = nil;
if (![blockSelf doSomethingWithItem:item error:&localError]) {
blockError = localError;
}
}];
// ...
As for exactly why this is necessary, I'm still trying to get a grasp on that myself. I'll update this answer when I do. :)