这是我的情况:
- (BOOL)textFieldShouldReturn:(UITextField *)textField{
dispatch_async(backgroundQueue, ^{
//Do long-running tasks
if(/*some condition*/){
//Continue long-running tasks
dispatch_async(dispatch_get_main_queue(), ^{
//UIKit stuff
});
return NO;
}else{
//Continue long-running tasks
dispatch_async(dispatch_get_main_queue(), ^{
//UIKit stuff
});
return YES;
}
});
}
由于该块是 void 返回类型,我得到了这个编译器错误:
Incompatible block pointer types passing 'BOOL(^)(void)' to parameter of type 'dispatch_block_t' (aka 'void(^)(void)')
如何解决?