应该如何使用showAlertViewForRequestOperationWithErrorOnCompletion?

时间:2013-12-10 21:24:03

标签: ios afnetworking-2

我不确定应该如何使用来自新AFNetworking的showAlertViewForRequestOperationWithErrorOnCompletion。我尝试了以下操作,但没有显示alertView。

[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id requestObject) {
    // ...
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    [UIAlertView showAlertViewForRequestOperationWithErrorOnCompletion:operation
                                                              delegate:nil];
}];

1 个答案:

答案 0 :(得分:1)

  1. 您确定要到达那行代码吗?
  2. 仅在操作错误为非零时才显示警报。你确定是这样的吗?
  3. <强>更新

    好的,所以implementation看来调用它并不会立即显示警报,而只是将其设置好以便在操作失败时显示警报。所以你可能需要这样做:

    [UIAlertView showAlertViewForRequestOperationWithErrorOnCompletion:requestOperation
                                                                  delegate:nil];
    
    [requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id requestObject) {
    
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    
    }];