I face a problem when develop an Iphone application and test it th开发者_运维技巧rough Iphone Simulator.
In my Iphone application, there exist a button. When I click on this button, the code will check whether the Iphone is connected to internet or not. If is connected, then it will start load data from server and then insert data to my application's local database. And show a view which display the loaded data. If internet is not connected, the didFailWithError method will called and pop up a alert to alert user "no internet connection".
But my problem is when the internet connection on my Mac is on, and I click that button, the data will be loaded successfully and display a view which consists the loaded data. Then I close that view, and off the internet connection on Mac, then I click that button again, the didFailWithError seems not get invoked. And a view will displayed to user too but the data is not updated, it seems look same as the data loaded from first time.
And for another case that is,once I start use the application, and off the internet connection on Mac first, and click that button for first time, the didFailWithError is invoked and alert user "No Internet Connection".
So, anyone encountered this kind of problem before? Or anyone have comments, suggestion and solutions?
Really appreciate your reply. Thanks.
So probably you have got the solution to your problem as this is very old question but I post answer incase you still need it.
The simple solution for it is use the reachabillity
class of apple's Reachability
just use this example to solve your problem.
精彩评论