//Called by Reachability whenever status changes.
- (void)reachabilityChanged: (NSNotification* )note
{
Reachability* curReach = [note object];
NSParameterAssert([curReach isKindOfClass: [Reachability class]]);
if (curReach == internetReach) {
NetworkStatus netStatus = [curReach currentReachabilityStatus];
switch (netStatus)
{
case NotReachable:
{
DDLogInfo(@"internet Reachability no internet");
}
break;
default:
{
DDLogInfo(@"internet Reachability has internet begin xmppStart");
[[[_xmppClient xmppiKnowFramework] xmppReconnect] manualStart];
}
break;
}
}
}
- (void)networkReachability {
// Observe the kNetworkReachabilityChangedNotification. When that notification is posted, the
// method "reachabilityChanged" will be called.
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(reachabilityChanged:)
name: kReachabilityChangedNotification
object: nil];
internetReach = [[Reachability reachabilityForInternetConnection] retain];
[internetReach startNotifier];
}
http://blog.youkuaiyun.com/yuhuangc/article/details/7410452