RestKit: RKRequest request in RKRequestQueue

I am trying to implement a download queue in my application. I put mine RKRequest

in RKRequestQueue

and call [queue start]

. But as we all know, a network connection is something that doesn't last forever. I am using RKReachabilityObserver

now to figure out when to suspend and resume my queue and it works fine (at least for now, however I have heard of some problems with reachability code in RestKit). This allows me to stop sending new data until the network is available again. But when the network connection is lost, all the active ones RKRequest

give out - (void)request:(RKRequest *)request didFailLoadWithError:(NSError *)error

where I thought I could put it back RKRequest

in the 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 am getting EXC_BAD_ACCESS

somewhere in the didFailLoadWithError

method RKRequest

.

My question is: how can I request RKRequest

?

+3


source to share


1 answer


Instead of canceling and adding to the queue, do:

[request send];

      



But the best solution for this would be to use RKClient, it will simplify things. You don't have to worry about queuing. The client has an RKRequestQueue instance and an RKRequestQueue instance and does all this behind the scenes, in particular, it adds all the requests configured for a given client to the client's request queue and sends them to you.

+1


source







All Articles