In my app I am using webservices. I have implemented the Network Reachability using Reachability class. But that checks only when i start my application.
Note that, while downloading the data if loss of signal or site down occurs, I want to show the alert window.
Can this be done with the use of Reachability class? If yes than how to implement this? If no than what is the other way to implement ?
Thanks in advance.
Yes you can do this with help of NSNotificationCenter
- (void) addReachability
{
//Use the Reachability class to determine if the internet can be reached.
[[Reachability sharedReachability] setHostName:kHostName];
//Set Reachability class to notifiy app when the network status changes.
[[Reachability sharedReachability] setNetworkStatusNotificationsEnabled:YES];
//Set a method to be called when a notification is sent.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityChanged:)
name:@"kNetworkReachabilityChangedNotification" object:nil];
}
- (void)reachabilityChanged:(NSNotification *)note
{
[AppDelegate updateStatus];
}