Completion block not being called. How to check validity?
Posted
by
HCHogan
on Stack Overflow
See other posts from Stack Overflow
or by HCHogan
Published on 2012-12-10T22:39:00Z
Indexed on
2012/12/10
23:04 UTC
Read the original article
Hit count: 301
I have this method which takes a block, but that block isn't always called. See the method:
- (void)updateWithCompletion:(void (^)(void))completion {
[MYObject myMethodWithCompletion:^(NSArray *array, NSError *error) {
if (error) {
NSLog(@"%s, ERROR not nil", __FUNCTION__);
completion();
return;
}
NSLog(@"%s, calling completion %d", __FUNCTION__, &completion);
completion();
NSLog(@"%s, finished completion", __FUNCTION__);
}];
}
I have some more NSLogs inside completion. Sometimes this program counter just blows right past the call to completion() in the code above. I don't see why this would be as the calling code always passes a literal block of code as input.
If you're curious of the output of the line containing the addressof operator, it's always something different, but never 0 or nil.
What would cause completion not to be executed?
© Stack Overflow or respective owner