如果他们失败,我正在尝试让我的应用重试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
失败,如何在不崩溃的情况下重试?
答案 0 :(得分:0)
您可以尝试访问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];