I am using ASIHTTPRequest. I need to know how to do the following events using it;
The following are the way i should be checking for the availability of the internet, but in which event should i add it to address the following issues;
self.remoteHostStatus = [[Reachability sharedReachability] remoteHostStatus];
self.internetConnectionStatus = [[Reachability sharedReachability] internetConnectionStatus];
self.localWiFiConnectionStatus = [[Reachability sharedReachability] localWiFiConnectionStatus];
1.) Applications like foursquare pops out an alert as soon as the internet is lost ? How is this done, and in what event should i code this ? (The user might be performing a task, and suddenly the wifi goes off, then i should pop up a warning, saying no wifi available)
2.) As soon as the internet/wifi is back i need to refresh and update the data. How is this done? (it should be listening continuously, and once the internet is back it should update that view)
There is a notification posted by Reachability called
kReachabilityChangedNotification.You can enforce the generation of that notification by using Reachability’s
First register for that notification – for example in
viewDidLoadof aUIViewController:Add the following method – for example to your
UIViewControllerimplementation.Now simply invoke
startNotifier– for example inviewDidLoadagain and you should be informed whenever any changes happen.Do not forget to remove yourself from that notification and to invoke
stopNotifierwhen done. Sticking to my example would mean that you should add this to yourviewDidUnloadimplementation.