开发者

iPhone - app crashing with poor internet connection

I have an iPhone app which communicates with a server to get the data being displayed. I have tested this app on a wifi connection and a good 3G connection. The app works without an issue. But if I test the app on a poor connection, the app crashes.

I get an XML from the server and parse it before displaying the data. I have put in the NSXMLParser method to show an alert if the parsing fails. The n/w connection code is also placed in try/catch blocks and we show an alert if the control goes to the catch block.

On a poor internet connection, the app just crashes (doesn't even go to the catch block) and checking the crash logs suggests the app could not get the complete response. Shouldn't it go to the catch block in that case? (I am using a wrapper class to make a synchronous connection)

This will always be an issue in any app using the internet if the connection is poor. Is there any way we can avoid this?

Tha开发者_开发百科nks.

I am using the code provided here as the base for creating connections and getting the response


This isn't a direct answer, but may I suggest the ASIHTTPRequest library? I searched around for a long time looking for a good networking library and this seemed to be pretty bullet-proof through all sorts of connection issues.

It took me an afternoon to remove the lousy library I wrote and to integrate it. The other nice thing about it is that it can be done asynchronously.

It is available here: http://allseeing-i.com/ASIHTTPRequest/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜