I\'m following the given example code
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager GET:@\"http://example.com/resour
The best is to create a subclass
(you can also the same way add cache policy)
TimeoutAFHTTPRequestSerializer.h
#import "AFURLRequestSerialization.h"
@interface TimeoutAFHTTPRequestSerializer : AFHTTPRequestSerializer
@property (nonatomic, assign) NSTimeInterval timeout;
- (id)initWithTimeout:(NSTimeInterval)timeout;
@end
TimeoutAFHTTPRequestSerializer.m
#import "TimeoutAFHTTPRequestSerializer.h"
@implementation TimeoutAFHTTPRequestSerializer
- (id)initWithTimeout:(NSTimeInterval)timeout {
self = [super init];
if (self) {
self.timeout = timeout;
}
return self;
}
- (NSMutableURLRequest *)requestWithMethod:(NSString *)method
URLString:(NSString *)URLString
parameters:(NSDictionary *)parameters
error:(NSError *__autoreleasing *)error
{
NSMutableURLRequest *request = [super requestWithMethod:method URLString:URLString parameters:parameters error:error];
if (self.timeout > 0) {
[request setTimeoutInterval:self.timeout];
}
return request;
}
@end
Use
self.requestOperationManager.requestSerializer = [[TimeoutAFHTTPRequestSerializer alloc] initWithTimeout:30];