几乎没有类似的问题可以回答,但找不到在我的代码上使用该解决方案的方法。如果有人可以帮助我编写代码,我会很高兴。如何重试超时请求?
while 用于分页目的的块:
while(mult < (int)totalCount) {
     AFHTTPRequestOperation *opr = [self getRequestForAllRecordsOfClass:className updatedAfterDate:mostRecentUpdatedDate withinPage:page+1];
     [pagedOperations addObject:opr];
     mult = mult + PAGINATION_SIZE;
     page = page + 1;
}
    [[SDAFParseAPIClient sharedClient] enqueueBatchOfHTTPRequestOperations:operations progressBlock:^(NSUInteger numberOfCompletedOperations, NSUInteger totalNumberOfOperations) {
             NSLog(@"totalNumberOfOperations: %u  numberOfCompletedOperations: %u",totalNumberOfOperations,numberOfCompletedOperations);
        } completionBlock:^(NSArray *operations) {
                     ...
}];
和构建请求操作
-(AFHTTPRequestOperation *)getRequestForAllRecordsOfClass:(NSString *)className updatedAfterDate:(NSDate *)mostRecentDate withinPage:(int)page  {
    NSMutableURLRequest *request = [ZurmoHelper GETRequestForAllRecordsOfClass:className updatedAfterDate:mostRecentDate inPage:page];
    AFHTTPRequestOperation *operation = [[SDAFParseAPIClient sharedClient] HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"RESPONSE pagination!!! %@:", className);
        NSError *error = nil; //error in parsing json
        NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:responseObject options:kNilOptions error:&error];
        if (!error) {
            NSLog(@"json dict paged in : %d",page );
            id dataObject = [jsonDict objectForKey:@"data"];
            NSArray *itemsObject = [dataObject objectForKey:@"items"];
            [self addItems:itemsObject className:className];
        }
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Request for class %@ failed with error: %@", className, error);
        if (error.code == -1001) {
            NSLog(@"for class %@ page: %d,",className,page);
            //need to retry this operation???
        }
    }];
    return operation;
}