在restkit 0.20.0中请求超时

use*_*374 8 restkit

我没有找到任何方法在restkit 0.20.0上设置超时间隔.

任何人都可以帮助增加超时间隔.

谢谢

小智 6

子类RKHTTPRequestOperation和实现方法

- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse
{
    NSMutableURLRequest *requestWithTimeout = [request mutableCopy];
    [requestWithTimeout setTimeoutInterval:30];

    return [super connection:connection willSendRequest:requestWithTimeout redirectResponse:redirectResponse];
}
Run Code Online (Sandbox Code Playgroud)


all*_*ire 5

RestKit现在使用AFNetworking作为HTTP层,因此您需要在Restkit的HTTPClient中设置它.请参阅 AFNetworking Github上的此问题.此外,AFNetworking的创建者Matt并不喜欢轻易打开超时属性的想法(请参阅此处的原因)

我希望这可以给你一些见解!