Skip to content
This repository was archived by the owner on Dec 5, 2019. It is now read-only.

Conversation

@caoer
Copy link

@caoer caoer commented Jul 2, 2015

when error is used inside a block of -enumerateKeysAndObjectsUsingBlock:. It setups an autorelease pool, by the time it returns, any out error will be deallocaed. we need to use __block, as in code *tmpError

I assume put error in enumerateKeysAndObjectsUsingBlock is equal to code below.

- (void)produceError3:(NSError **)error {
    void (^errorProduceBlock)() = ^{
        @autoreleasepool {
            *error = [NSError errorWithDomain:@"AWESOME ERROR" code:0 userInfo:nil];
        }
    };

    errorProduceBlock();
}
- (void)produceError5:(NSError **)error {
    [@{@"DD":@"YY"} enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
        *error = [NSError errorWithDomain:@"AWESOME ERROR" code:0 userInfo:nil];
    }];
}

Both code will crash. But I don't know why MTLManagedObjectAdapter won't crash, it will just silently ignore the error.

when error is used inside a block of *-enumerateKeysAndObjectsUsingBlock:*. It setups an autorelease pool, by the time it returns, any out error will be deallocaed. we need to use __block, as in code *tmpError
@caoer
Copy link
Author

caoer commented Jul 2, 2015

I think this also addressed some of the discussion in Mantle/Mantle#120

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant