首页 > 代码库 > AFNetworking 取消请求

AFNetworking 取消请求

取消单个操作:

AFHTTPRequestOperation *operation
     = [[AFHTTPRequestOperation alloc] initWithRequest:request];

[operation cancel];

或者

AFHTTPRequestOperation *operation 
    = [postManager POST:request.methodUrl
             parameters:parameters
                success:^(AFHTTPRequestOperation *operation,
                          id responseObject) {
                          }failure:^(AFHTTPRequestOperation *operation,
                              NSError *error){
        }];

[operation cancel];

取消全部操作:

AFHTTPRequestOperationManager *httpmanager 
    = [AFHTTPRequestOperationManager manager];

[httpManager.operationQueue cancelAllOperations];
<script type="text/javascript"> $(function () { $(‘pre.prettyprint code‘).each(function () { var lines = $(this).text().split(‘\n‘).length; var $numbering = $(‘
    ‘).addClass(‘pre-numbering‘).hide(); $(this).addClass(‘has-numbering‘).parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($(‘
  • ‘).text(i)); }; $numbering.fadeIn(1700); }); }); </script>

AFNetworking 取消请求