¡@

Home 

2014/10/15 ¤U¤È 10:09:57

iphone Programming Glossary: handlenetworkchange

iPhone reachability checking

http://stackoverflow.com/questions/1861656/iphone-reachability-checking

instances Reachability reachability in .m file NSNotificationCenter defaultCenter addObserver self selector @selector handleNetworkChange name kReachabilityChangedNotification object nil reachability Reachability reachabilityForInternetConnection reachability.. if remoteHostStatus ReachableViaWiFi NSLog @ wifi else if remoteHostStatus ReachableViaWWAN NSLog @ cell ..... void handleNetworkChange NSNotification notice NetworkStatus remoteHostStatus reachability currentReachabilityStatus if remoteHostStatus NotReachable..

Reachability network change event not firing

http://stackoverflow.com/questions/4501864/reachability-network-change-event-not-firing

And this works fine. in viewDidOnload NSNotificationCenter defaultCenter addObserver self selector @selector handleNetworkChange name kReachabilityChangedNotification object nil reachability Reachability reachabilityForInternetConnection reachability.. reachability currentReachabilityStatus if status NotReachable Do something offline else Do sometihng on line void handleNetworkChange NSNotification notice NetworkStatus status reachability currentReachabilityStatus if status NotReachable Change to offline.. currentReachabilityStatus if status NotReachable Change to offline Message else Relaunch online application To test my handleNetworkChange event I turned off all cellular data but left the wifi on. Within range of the wifi I started the app and everything works..