2013-03-19 65 views
0

我的應用程序崩潰,每次都從沒有網絡的網絡狀態更改爲網絡或反之亦然,在與EXC_BAD_ACCESS以下行:可達崩潰每次網絡更改狀態

dispatch_async(dispatch_get_main_queue(), ^{ 
     [[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification 
                  object:self]; 
    }); 

林通過應用程序代理使用電話:

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

    internetReach = [Reachability reachabilityForInternetConnection]; 
    [internetReach startNotifier]; 
    [self checkNetworkStatus:nil]; 

-(void) checkNetworkStatus:(NSNotification *)notice 
{ 
    // called after network status changes 
    NetworkStatus internetStatus = [internetReach currentReachabilityStatus]; 
    switch (internetStatus) 
    { 
     case NotReachable: 
     { 
      NSLog(@"The internet is down."); 
      break; 
     } 
     case ReachableViaWiFi: 
     { 
      NSLog(@"The internet is working via WIFI."); 
      break; 
     } 
     case ReachableViaWWAN: 
     { 
      NSLog(@"The internet is working via WWAN."); 
      break; 
     } 
    } 

} 

任何人都知道如何解決這一問題?

+0

你有沒有找到合適的解決方案,因爲我面臨類似的問題? – itsji10dra 2015-06-02 08:26:05

回答