Internet reachability with iphone
I need to restart a download automatically when a connection goes down and then comes back up. Actually I'm using the Reachability class example from Apple but I have a problem when the switch down and up wi-fi application restarts the download, but this does not happen if I have wi-fi but not an internet connection. To do this I check connection and I register method to notification but this notification is never fired.
hostReach = [NaviReachability reachabilityWithHostName:@"www.apple.com"]; internetReach = [NaviReachability reachabilityForInternetConnection]; wifireach = [NaviReachability reachabilityForLocalWiFi]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resumeDownloadOnNotification:) name:@"kNetworkReachabilityChangedNotification" object:nil];
[hostReach startNotifer]; [internetReach startNotifer]; [wifireach startNoti开发者_JAVA技巧fer]; Blockquote
I noticed that if my application makes a connection (or iphone receives or sends something from internet) the notification arrives, and the method is executed.
Do any of you have any suggestions?
From what I hear the Reachability class is poorly written and one guy has gone as far as to refactor and improve it. He also offers an explanation of how to use his improved version. Maybe it can be of use to your project.
精彩评论