Ios 网络调用中嵌套异步完成块的解决方法?不使用承诺书

Ios 网络调用中嵌套异步完成块的解决方法?不使用承诺书,ios,objective-c,objective-c-blocks,Ios,Objective C,Objective C Blocks,基本上,我有一个现有的API管理器,它阻止我前进。这个现有的经理是我现在不应该惹的 这就是我问题的要点。我的意思是,我可以继续这样做,但这太烦人了。我讨厌这些嵌套的完成块。有人有解决这个问题的办法吗?PromiseKit是不可选择的 这就是我所说的 - (void)doEverythingHere { [self getDataOneWithCompletion:^(DataOneModel *response) { if (response.isSomethin

基本上,我有一个现有的API管理器,它阻止我前进。这个现有的经理是我现在不应该惹的

这就是我问题的要点。我的意思是,我可以继续这样做,但这太烦人了。我讨厌这些嵌套的完成块。有人有解决这个问题的办法吗?PromiseKit是不可选择的

这就是我所说的

- (void)doEverythingHere {
    [self getDataOneWithCompletion:^(DataOneModel *response) {
            if (response.isSomething) {
                [self getDataTwoWithCompletion:^(DataOneModel *response) {
                    // And call some more of these...
                    // So the nested blocks will never end... and it's ugly
                };
            } else {
                [self getDataThreeWithCompletion:^(DataOneModel *response) {
                    // And call some more of these...
                    // So the nested blocks will never end... and it's ugly
                };
            }
    }];
}
这些是SAMPLAPI方法

- (void)getDataOneWithCompletion:(void(^)(DataOneModel *response))completion {
    [APIManager getDataOneWithResponse:^(DataOneModel *response) {
        completion(response)
    }];
}

- (void)getDataTwoWithCompletion:(void(^)(DataTwoModel *response))completion {
    [APIManager getDataTwoWithResponse:^(DataTwoModel *response) {
        completion(response)
    }];
}

// And 4 more of these API call methods.

是的,这有点笨拙,承诺/未来是一个解决方案。另一个是定制的异步
NSOperation
子类,它具有依赖性或类似的特性,尽管我不确定这是否值得。简单的解决方案是功能分解,将塔分解为一系列单独的功能,每个功能都处理下一级嵌套。对不起,我首先将此作为答案发布,但它应该是一个注释。为什么它不工作或阻塞?这种筑巢肯定不会永远持续下去?即便如此,它也应该起作用,但我遗漏了什么?也许您需要在不同的线程上进行嵌套调用以防止阻塞。