如果它们失败,我试图使我的应用重试RKRequests
。我正在尝试这样做:
- (void)objectLoader:(RKObjectLoader *)objectLoader didFailWithError:(NSError *)errorIn
{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate.waitView stop];
NSInteger code = objectLoader.response.statusCode;
if (201 != code && 200 != code)
{
// determine whether to requeue the request or not
if ([objectLoader.userData isEqualToString:@"capture"]) // requeue captures
{
NSLog(@"requeueing request");
[objectLoader.queue cancelRequest:objectLoader];
[objectLoader send];
}
}
}
...但它总是崩溃,因为
objectLoader
似乎是cancelRequest
行之后的悬挂指针。如果RKRequest
失败,如何重试而不崩溃? 最佳答案
您可以尝试访问RKRequest,例如使用RKRequestDelegate协议:
- (void)request:(RKRequest *)request didFailLoadWithError:(NSError *)error
因为那样您可以执行以下操作:
NSAssert(!request.isUnsent && !request.isLoading, @"Cant retry load, current attempt has not completed");
[request reset];
[request send];
关于ios - RestKit:如何重试失败的请求?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12152683/