我正在使用 Apple 提供的 Rechablity.h 和 Rechablity.h 并使用这些文件并添加了一些代码,例如
#pragma mark Rechability method
/**
* reachabilityChanged()
* @desc Check the internet connection
* @param NSNotification note is the notification of internet state changed
*/
- (void) reachabilityChanged: (NSNotification* )note {
Reachability* curReach = [note object];
NSParameterAssert([curReach isKindOfClass: [Reachability class]]);
[self updateInterfaceWithReachability: curReach];
}
/**
* updateInterfaceWithReachability()
* @desc Update the internet connection state
* @param Reachability curReach is the instance of Reachbility
*/
- (void) updateInterfaceWithReachability: (Reachability*) curReach {
if(curReach == internetReach) {
NetworkStatus netStatus = [curReach currentReachabilityStatus];
BOOL connectionRequired = [curReach connectionRequired];
NSString* statusString = @"";
switch (netStatus) {
case NotReachable: {
statusString = @"Access Not Available";
connectionRequired = NO;
isInternetAvailable = FALSE;
break;
}
case ReachableViaWWAN: {
statusString = @"Reachable WWAN";
isInternetAvailable = TRUE;
break;
}
case ReachableViaWiFi: {
statusString = @"Reachable WiFi";
isInternetAvailable = TRUE;
break;
}
}
if(connectionRequired)
statusString = [NSString stringWithFormat: @"%@, Connection Required", statusString];
//UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Gmmabling Gambit" message:statusString delegate:nil cancelButtonTitle:nil otherButtonTitles:@"Ok",nil];
// [alert show];
// [alert release];
//NSLog(@"%@",statusString);
}
}
/**
* internetCheck()
* @desc store the internet connection state
* @return BOOL internet is available or not
*/
- (BOOL)internetCheck {
return isInternetAvailable;
}
添加了 systemConfiguration.framework 和 Security.framework 但出现此类错误
clang: error: linker command failed with exit code 1 (use -v to see invocation)