2013-04-08 2 views
0
내가 연결이 없을 때 ASIReachability 작동 내 응용 프로그램에서 작동하도록하기 위해 노력하고있어

로 전송 있지만 연결은 다음과 같은 오류주고있는 경우 :는 [NSConcreteNotification은의 isReachable] : 인식 할 수없는 선택기 예를

2013 -04-08 12 : 26 : 20.501 Llanelli 도우미 [1576 : 207] - [NSConcreteNotification isReachable] : 인식 할 수없는 선택기가 인스턴스로 전송 됨 0x7d84d30

이 문제를 해결할 수없는 것 같아서 저를 괴롭히기 시작합니다.

하는 .m 파일 : 누군가가 나를 위해이 알아낼 수 있다면

- (void) CheckIfAInternetConnectionExists 
{ 
    Reachability *reach = [[Reachability reachabilityWithHostName:@"http://176.31.101.181:8020/listen.pls"]retain ]; 

    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(reachabilityChanged:) 
               name:kReachabilityChangedNotification 
               object:nil]; 
    [reach startNotifier];  
} 

- (void) reachabilityChanged:(Reachability *)reach { 
    if ([reach isReachable ]) { 
     NSLog(@"connection"); 
     ServerFound = YES; 
     [self PrepareStream]; 
    } else{ 
     NSLog(@"no connection"); 
     ServerFound = NO; 
     [self PrepareStream]; 
    } 
} 

나는 매우 감사하게 될 거라고.

+0

덕분에 빠른 응답을, 그것을 찾을 수 없습니다 연결을 유발하지 유지 어떤 이유로. 서버를 찾지 못합니다. –

답변

4

알림을 받으면 reachabilityChanged: 메서드의 매개 변수가 알림 자체가됩니다. Reachability 개체를 얻으려면 알림에서 -[NSNotification object]을 보내서 알림에서 가져와야합니다.

그래서이 같은 작업을해야합니다 :

- (void) reachabilityChanged:(NSNotification *)note { 

    Reachability *reach = [note object]; 

    if ([reach isReachable ]) { 
     NSLog(@"connection"); 
     ServerFound = YES; 
    } else{ 
     NSLog(@"no connection"); 
     ServerFound = NO; 
    } 

    [self PrepareStream]; 

    }