Notification is not called in reachability

I used the modified Reachability Andrew class.

-(void)viewDidLoad [[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification object:nil]; [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil]; 

When downloading data, I disable AirPort . But checkNetworkStatus not called. I'm missing something. Please help me. This problem is driving me crazy. Thanks in advance.

+4
source share
4 answers

put it in this sequence

In ur ​​view booted

First register

then

post this notice

 [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil]; [[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification object:nil]; 
+2
source

Did you tell the reachability instance to start sending notifications?

 Reachability *internetReachable = [Reachability reachabilityForInternetConnection]; // This will tell the notifier to start sending notifications [internetReachable startNotifier]; 
+9
source

I have exactly the same problem, the Apple example works fine, so I will eventually replace the Reachability class with the Apple version, everything works fine. It cost me almost 2 hours.

Just replace Reachability.h, .m from the Apple example, everything should just work.

+2
source

This worked for me (Swift):

 func handleNetworkChange(notification:NSNotification) { ... } NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("handleNetworkChange:"), name: kReachabilityChangedNotification, object: nil) ReachabilityChecker = Reachability.reachabilityForInternetConnection() ReachabilityChecker!.startNotifier() 
+2
source

All Articles