7
A
回答
5
RestKit现在使用AFNetworking为它的HTTP层,所以你需要将其设置在Restkit的HttpClient的。 AFNetworking Github上的See this Issue。另外,AFNetworking的创建者Matt并不喜欢轻松打开超时属性的想法(see his reason here)
我希望这能给你一些见解!
5
子类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];
}
+0
不适用于我。 RestKit0.26.0我将尝试这种方法http://stackoverflow.com/a/16885658/3389683 –
2
完整代码
更精细/描述性的,我的代码是如下:
RKHTTPRequestOperation_Timeoutable.h
#import "RKHTTPRequestOperation.h"
@interface RKHTTPRequestOperation_Timeoutable: RKHTTPRequestOperation
- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse;
@end
RKHTTPRequestOperation_Timeoutable .m
#import "RKHTTPRequestOperation_Timeoutable.h"
@implementation RKHTTPRequestOperation_Timeoutable
- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse
{
NSMutableURLRequest *requestWithTimeout = [request mutableCopy];
[requestWithTimeout setTimeoutInterval:150];//2.5 minutes
return [super connection:connection willSendRequest:requestWithTimeout redirectResponse:redirectResponse];
}
@end
然后(这是帮助我知道,这是不是在其他的答案中提到的部分),您注册类RKObjectManager。
像这样(请原谅我的矛盾,这是迅速没有目标C我的代码只有段):
RKObjectManager.sharedManager().registerRequestOperationClass(Timeoutable);
相关问题
- 1. iOS/RestKit - 请求超时
- 2. RestKit 0.20.0 - getObjectsAtPath使用JSON HTTP请求的身体
- 3. RestKit 0.27 - 设置请求超时
- 4. Restkit .20请求超时间隔
- 5. 请求超时 - 请求超时
- 6. RestKit 0.20.0-rc1 - POST后的重复对象
- 7. NSURL请求超时请求
- 8. 请求超时
- 9. node.js请求中的超时
- 10. cast.Api.loadMedia()中的请求超时
- 11. ios5中的请求超时
- 12. API.AI中的请求超时
- 13. RestKit:在RKRequestQueue中请求RKRequest
- 14. RestKit请求嘲弄
- 15. POST请求的请求超时(H-12)
- 16. Restkit:在所有的请求
- 17. Corba请求超时
- 18. KSoap请求超时?
- 19. HTTP请求超时
- 20. NSURLSession - 请求超时
- 21. Ajax请求超时
- 22. Web请求超时
- 23. IIS请求超时
- 24. SharePoint - “请求超时”
- 25. Tomcat请求超时
- 26. 超时ASIHTTP请求
- 27. NSXMLParser - 请求超时
- 28. 请求超时:检索文件时GET请求超时
- 29. 防止长请求请求超时
- 30. RestKit:区分didLoadResponse中的多个请求:
似乎没有被设置在超时的方式RestKit 2.0 HTTPClient。 –