How can I stop a request(timeout) in AFNetworking if I started a request but no response data for a while such as 30 seconds
            Asked
            
        
        
            Active
            
        
            Viewed 1,593 times
        
    2
            
            
        - 
                    `[operation cancel];` – Preetam Jadakar Oct 10 '13 at 04:55
 - 
                    refere http://stackoverflow.com/questions/8304560/how-to-set-a-timeout-with-afnetworking – Preetam Jadakar Oct 10 '13 at 05:16
 
1 Answers
1
            You need to initialize your NSURLRequest with a timeout value that fits your needs.
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:inURL
 cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30.0];
Then, initialize AFNetworking's AFHTTPRequestOperation with that initialized NSMutableURLRequest request.
        Toseef Khilji
        
- 17,192
 - 12
 - 80
 - 121
 
- 
                    ok,it's helpful.but I don't understand why Matt who's the author of AFNetWorking use the method:NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url]; but not NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:inURL cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30.0];? – LiMo Oct 10 '13 at 06:03
 - 
                    See Matt's answer to [this](http://stackoverflow.com/questions/8304560/how-to-set-a-timeout-with-afnetworking) question. – David Gish Oct 25 '13 at 22:03