1

回答のある同様の質問はほとんどありませんが、コードでそのソリューションを使用する方法が見つかりませんでした。誰かがコードで私を助けてくれればうれしいです。タイムアウト要求を再試行するには?

ページネーション用の 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;

}
4

0 に答える 0