是否有一种方法可以等待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,但是我想知道是否有更好的方法。
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!)
}
}