iPhoneDev
iPhoneDev

Reputation: 3015

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 in background to check response

c. Notification class (I never used it)

Thanks

Upvotes: 0

Views: 541

Answers (1)

Reena
Reena

Reputation: 845

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

Upvotes: 2

Related Questions