1
votes

I'm looking for a way to set a request timeout on a basic RKObjectManager getObjectsAtPath: parameters: success: failure: request, in RestKit v.0.27.0

Right now, if a user reaches a view, triggers this request, and his internet shutdowns, nothing will happen, it will just keep on loading for an extremely long time. How can I manually change the timeout time to a certain time (for instance 15 seconds)?

1

1 Answers

0
votes

To detect when the internet connection of the client is gone, Apple published the Reachability class a long time ago. If you're not using it, feel free to use this tutorial for a quick start.

As written in the tutorial, you're able to respond when the reachability is gone and therefore can cancel all pending requests.

- (void)reachabilityDidChange:(NSNotification *)notification {
    Reachability *reachability = (Reachability *)[notification object];

    if ([reachability isReachable]) {
        NSLog(@"Host is reachable");
    } else {
        NSLog(@"Host is unreachable");

        // Cancel all pending RestKit requests
        [[RKObjectManager sharedManager].operationQueue cancelAllOperations];
    }
}