1

I need to be notified when the network status change. I already found how to check network reachability in other topic.

Is there any delegate which I can use to do that?

Community
  • 1
  • 1

1 Answers1

1

Assuming you're using the code from Apple's Reachability sample project you'll want to register for the kReachabilityChangedNotification notification.

Assuming you have a UIViewController subclass that has the method:

func handleReachabilityChanged(notification:NSNotification)
{
    // notification.object will be a 'Reachability' object that you can query
    // for the network status.

    NSLog("Network reachability has changed.");
}

Then you'll want to register for that notification in your UIViewController's viewDidLoad() method like this:

let nc = NSNotificationCenter.defaultCenter();
nc.addObserver(self, selector:"handleReachabilityChanged:", name:kReachabilityChangedNotification, object:nil);

See the NSNotificationCenter and NSNotification documentation for how to setup and teardown notification handlers.

A. R. Younce
  • 1,913
  • 17
  • 22