Reputation: 3618
getObject
with a list of IDs. getObject
s calls. The problem is that any one of those multiple getObject
gets cancelled (error -999
).
RKObjectManager *objectManager = [RKObjectManager sharedManager];
- (void)firstGetListOfIDs
{
A *a = [A new];
[objectManager getObject:a
path:nil
parameters:parameters
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
for (NSString* anID in a.listOfIDs)
[self thenGetObjectForID:anID];
} failure:nil];
}
- (void)thenGetObjectForID:(NSString*)anID
{
B *b = [B new];
[objectManager getObject:b
path:nil
parameters:parametersWithAnID
success:^(RKObjectRequestOperation *operation, RKMappingResult *mappingResult) {
} failure:nil];
}
That is, each getObject
call (in thenGetObjectForID:
above) errors on lines 211
and 552
in RKObjectRequestOperation.m
:
E restkit.network:RKObjectRequestOperation.m:211 GET 'http://domain.com/sdk/b?id=anID' (0 / 0 objects) [request=0.0000s mapping=0.0000s total=0.0006s]: Cancelled
E restkit.network:RKObjectRequestOperation.m:552 Object request failed: Underlying HTTP request operation failed with error: Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)" UserInfo=0x134772e0 {NSErrorFailingURLKey=http://domain.com/sdk/b?id=anID}
Now, I can remedy this by adding [objectManager.operationQueue waitUntilAllOperationsAreFinished];
but, alas this blocks the main thread. How to make multiple, asynchronous getObject
requests?
I've tried using RKObjectManager
's enqueueBatchOfObjectRequestOperations:progress:completion:
, though not sure if properly.
Upvotes: 0
Views: 403
Reputation: 3618
The culprit turned out to be a vagabond [[RKObjectManager sharedManager] cancelAllObjectRequestOperationsWithMethod:matchingPathPattern:];
call.
Upvotes: 0
Reputation: 119031
You should upgrade to the latest (or at least not a pre) version of RestKit.
Generally, your code looks fine and you should be able to make multiple concurrent requests. You should set the maximum number of concurrent operations on objectManager.operationQueue
to around 5 though or you may flood the system and all requests will timeout.
Upvotes: 1