开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜