开发者

Request TimeOut in iPhone XML/JSON request

开发者 https://www.devze.com 2023-01-07 02:57 出处:网络
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 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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号