Używam tego kodu do sprawdzenia połączenia z internetem, ale jestem coraz awarię mówiąc +[Reachability reachabilityForInternetConnection]: unrecognized selector sent to class 0xcbe0c8
App upaść podczas korzystania osiągalności klas w celu sprawdzenia połączenia internetowego
mam importowane Reachability .h/.m i ram systemconfig. Crash przy linii self.internetRechable = [[Reachability reachabilityForInternetConnection] retain];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(checkNetworkStatus:) name:kReachabilityChangedNotification object:nil];
self.internetRechable = [[Reachability reachabilityForInternetConnection] retain];
[self.internetRechable startNotifier];
// check if a pathway to a random host exists
self.hostReachable = [[Reachability reachabilityWithHostName: @"www.apple.com"] retain];
[self.hostReachable startNotifier];
- (void) checkNetworkStatus:(NSNotification *)notice
{
// called after network status changes
NetworkStatus internetStatus = [self.internetRechable currentReachabilityStatus];
switch (internetStatus)
{
case NotReachable:
{
NSLog(@"The internet is down.");
// self.internetActive = NO;
break;
}
case ReachableViaWiFi:
{
NSLog(@"The internet is working via WIFI.");
// self.internetActive = YES;
break;
}
case ReachableViaWWAN:
{
NSLog(@"The internet is working via WWAN.");
// self.internetActive = YES;
break;
}
}
NetworkStatus hostStatus = [self.hostReachable currentReachabilityStatus];
switch (hostStatus)
{
case NotReachable:
{
NSLog(@"A gateway to the host server is down.");
// self.hostActive = NO;
break;
}
case ReachableViaWiFi:
{
NSLog(@"A gateway to the host server is working via WIFI.");
// self.hostActive = YES;
break;
}
case ReachableViaWWAN:
{
NSLog(@"A gateway to the host server is working via WWAN.");
// self.hostActive = YES;
break;
}
}
}
Nie, robiłem '@class Reachability' a ja importowane jako dobrze – Jon
Tak, ive importowane pliki i zrobiłem' #import "Reachability.h" 'itp – Jon
zrobiłem, że jego awaria w 'Dostępności * newReach = [osiągalność osiągalności dlaInternetConnection];' – Jon