Request TimeOut in iPhone XML/JSON request
Which is the best way to handle request-timeout. I am sending XML request and if I didn't get response in 10 sec I need to stop activity indicator and show alert message.
Which approach is best out of following:
a. NSTimer - To check status of response
b. NSThread - This will run 开发者_C百科in background to check response
c. Notification class (I never used it)
Thanks
If you use NSMutableURLRequest then you can give time interval in this
for eg.
NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0];
so no need to use timer or thread
精彩评论