How to return outer function from inside async inner function in Objective-C

前端 未结 2 1413
一向
一向 2020-12-20 09:01

I want to return from outer function from inside async inner function. In swift, I would have used completion handler for this purpose which would escape from function. But

2条回答
  •  渐次进展
    2020-12-20 09:21

    Easier is just to call another function that tells it's completed.

    -(void)chosenFrom:(NSDictionary *)info{
    
        [self asyncCode:info withCompletion:^(NSData *imageData) {
            if(imageData) {
                 [self completedAsync:imageData];
            }
        }];
    
    }
    
    -(void)completedAsync:(NSData*) imageData {
      // do your thang.
    }
    

提交回复
热议问题