我AFJSONRequestOperation
从两个视图控制器运行两个,它们一个接一个地被调用:
视图控制器1:
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON){
//
}failure:^(NSURLRequest *request, NSHTTPURLResponse *response,NSError *error, id JSON){
//
}];
[operation start];
[SVProgressHUD showWithStatus:@"Searching for products, please wait.."];
视图控制器2:
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON){
//
}failure:^(NSURLRequest *request, NSHTTPURLResponse *response,NSError *error, id JSON){
//
}];
[operation start];
[SVProgressHUD showWithStatus:@"Loading categories.."];
问题是显示的状态仅适用于第二次操作:Loading categories..
尽管他们完成了联网并获得 JSON 结果都很好。
似乎我无法使用NSOperationQueue
,因为这两个操作位于单独的控制器中。那么如何确保一个人等到第一个完成后才向用户显示两个状态消息呢?