开发者

iPhone SDK : Asynchronous Connection Retry Mechanism

开发者 https://www.devze.com 2023-01-03 04:41 出处:网络
I have implemented the usual Asynchronous connection mode in one of my apps and it works fine. The error handling is also hap开发者_运维技巧pening properly. I also have implemented the Reachability AP

I have implemented the usual Asynchronous connection mode in one of my apps and it works fine. The error handling is also hap开发者_运维技巧pening properly. I also have implemented the Reachability API by Apple.

I would like to have for example 5 retires to be done when there is a network failure.

Kindly suggest me a good way to implement this.


Implementing the retry option was simple actually.

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error

Use this method to make sure you identify the error condition while a try is failed. You can reinitiate the request again inside this method with a int flag has the NO_MAX_RETRY(eg.5) set.

- (void)connectionDidFinishLoading:(NSURLConnection *)connection this method when returned the connection is successful and you can reset the retry flag and release the retry routine.

0

精彩评论

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

关注公众号