Search code examples
iphoneios4reachability

Notification is not being called in Reachability


I have used Andrew's modified Reachability class.

-(void)viewDidLoad

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

When data is downloading I turn AirPort off. But checkNetworkStatus is not being called. Am I missing something. Please help me. This problem driving me nuts. Thanks in advance.


Solution

  • put it in this sequence

    in ur view did load

    First register

    then

    post that notification

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