title: RestKit: How to retry a failed request?
body: <p>I'm trying to make my app retry <code>RKRequests</code> if they fail. I'm trying to do it this way:</p>
  
  <pre><code>- (void)objectLoader:(RKObjectLoader *)objectLoader didFailWithError:(NSError *)errorIn
  {
      AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
      [appDelegate.waitView stop];
  
      NSInteger code = objectLoader.response.statusCode;
  
      if (201 != code &amp;&amp; 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];
          }
      }
  }
  </code></pre>
  
  <p>... but it always crashes because <code>objectLoader</code> seems to be a dangling pointer after the <code>cancelRequest</code> line. If an <code>RKRequest</code> fails, how do I retry it without crashing?</p>