2012-04-04 4 views
0

내 프로젝트에서 도달 가능성을 사용하고 있으며 연결 유형에 대한 정보를 얻으려고하면이 오류가 발생합니다.연결 가능성이있는 연결 상태

*** Assertion failure in -[Reachability currentReachabilityStatus],/myProjectPath/Reachability.m:530 
2012-04-03 21:25:45.619 Traffic[7862:11603] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'currentNetworkStatus called with NULL reachabilityRef' 

내 코드에 어떤 문제가 있는지 알 수 없습니다. ReachabilityAppDelegate에서와 동일한 코드를 연결 상태에 연결합니다.

내 코드 : 응용 프로그램의 위임에

//Called by Reachability whenever status changes. 
- (void) reachabilityChanged: (NSNotification*)note 
{ 
    Reachability* curReach = [note object]; 
    NSParameterAssert([curReach isKindOfClass: [Reachability class]]); 
    [self updateInterfaceWithReachability: curReach]; 
} 

: 대한

// get type of user connection 
NSString* statusString= @"NA"; 

Reachability *curReach = [[Reachability alloc] init]; 
NetworkStatus netStatus = [curReach currentReachabilityStatus]; 
BOOL connectionRequired= [curReach connectionRequired]; 


switch (netStatus) 
{ 
    case NotReachable: 
    { 
     statusString = @"NA"; 
     //Minor interface detail- connectionRequired may return yes, even when the host is unreachable. We cover that up here... 
     connectionRequired= NO; 
     break; 
    } 

    case ReachableViaWWAN: 
    { 
     statusString = @"WWAN"; 
     break; 
    } 
    case ReachableViaWiFi: 
    { 
     statusString= @"WIFI"; 
     break; 
    } 
} 

답변

0

확인하시기 바랍니다. NSParameterAssert가 내 문제의 원인이됩니다.

0

같은 문제가있었습니다. 내가

reachability = Reachability.forInternetConnection() 
reachability.startNotifier() 

문제를하기 전에 if reachability.currentReachabilityStatus() == NotReachable 확인되었다 알리미를 시작하기 전에 상태를 요구하고 있는지, 그리고 _reachabilityRef은 전무하다.

필요한 순서대로 통화를해야합니다. 첫 번째 알림을 시작한 다음 해당 확인 후에 만 ​​/ 상태를 요청합니다.