Reputation: 75
I have 2 fairly simple question. I have 2 mapped requests sent i close succession to each other, called by MAIN thread.
First request: [[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"SomePathToServer"delegate:self]
Second request:
[[RKObjectManager sharedManager] loadObjectsAtResourcePath:@"SomeOTHERpathtoServer" delegate:self];
My question is: Are they automatically queued by the object manager?
When i run them now the first request will trigger a rather large syncing communication with the webservice. The second request i fired off in the midst of that communication and is not handled/Recieved by RestKit.
If i run my app again, my code detect that the syncing is done, and now the second request is handled - Data is recieved and mapped.
Do i have to manually add my managed requests to a queue?
I havent found anything about it on the net, so if i have to manually queue it, i wonder if someone has an example or directions to a guide. I have only found queing examples for simple requests, and i have no idea on how to put the First and Second request into the queue - if needed. Help is much appreciated. Thomas
Upvotes: 0
Views: 1383
Reputation: 142
RKRequestQueue will do the job. You can add to the queue either RKObjectLoader or RKRequest
Here is the example:
RKRequestQueue *queue =[[RKRequestQueue alloc] init];
queue.delegate = self;
queue.concurrentRequestsLimit = 1;
queue.showsNetworkActivityIndicatorWhenBusy= YES;
[queue addRequest:[[RKObjectManager sharedManager] objectLoaderWithResourcePath:@"resource" delegate:self]];
[queue addRequest:[RKClient sharedClient] requestWithResourcePath:@"Another Resource "delegate: self]];
[queue start];
Upvotes: 2