iOS Box API-等待请求完成

问题描述 投票:0回答:1

是否有一种方法可以等待Box API完成所有请求?因此,例如,如果我请求一个文件夹项目,我希望让我的程序等待完成处理程序完成后再继续。

例如:

BOXContentClient *contentClient = [BOXContentClient defaultClient];

BOXFolderItemsRequest *listAllInRoot = [contentClient folderItemsRequestWithID:BOXAPIFolderIDRoot];

[listAllInRoot performRequestWithCompletion:^(NSArray *items, NSError *error) {
    //Do something with the results here
}

// Wait here for the completion handler to finish before moving on

我曾经尝试使用NSCondition,但是我想知道是否有更好的方法。

objective-c box-api
1个回答
1
投票
var a: [String:Any] func myFunction(completion:@escaping (Bool) -> () ) { DispatchQueue.main.async { // For example your action on a } } myFunction { (status) in if status { print(a!) } }
© www.soinside.com 2019 - 2024. All rights reserved.