Reputation: 1587
I'm trying to implement an upload queue in my application. I'm putting my RKRequest
s into RKRequestQueue
and call [queue start]
. But, as we all know, network connection is something that is not lasts forever. I'm using RKReachabilityObserver
now to determine when to suspend and resume my queue, and it is working fine (at least now, however I've heard about some issues with reachability code in RestKit). This lets me to stop sending new data until network is available again. But when network connection is lost, all active RKRequest
s are issuing - (void)request:(RKRequest *)request didFailLoadWithError:(NSError *)error
where, I thought, I will be able to put my RKRequest
back in queue again.
So, I tried this:
- (void)request:(RKRequest *)request didFailLoadWithError:(NSError *)error
{
NSLog(@"Request failed");
[[request queue] cancelRequest:request];
[[request queue] addRequest:request];
}
but I'm getting an EXC_BAD_ACCESS
somewhere in didFailLoadWithError
method of RKRequest
.
My question is: how can I requeue a RKRequest
?
Upvotes: 3
Views: 1097
Reputation: 7344
Instead of cancelling and adding to queue, do:
[request send];
But the best solution for this would really be to use RKClient, it makes things easier. You would not have to worry about queue. The client comes with and instance of RKRequestQueue and does all the magic behind the scenes, specifically it adds all requests configured for the given client to the clients request queue and dispatches them for you.
Upvotes: 1