我已经尝试检查是否存在与google.com的连接 但是这种方法不能正常工作? 你能告诉我我的错吗? 你的拉斐尔
- (BOOL)networkConnected {
SCNetworkReachabilityFlags flags = 0;
SCNetworkReachabilityRef netReachability;
BOOL retrievedFlags = NO;
netReachability = SCNetworkReachabilityCreateWithName(CFAllocatorGetDefault(), [@"http://www.google.com" UTF8String]);
if (netReachability) {
retrievedFlags = SCNetworkReachabilityGetFlags(netReachability, &flags);
CFRelease(netReachability);
}
if (!retrievedFlags || !flags) {
NSLog(@"no");
return NO;
}
NSLog(@"yes");
return YES;
}
答案 0 :(得分:1)
答案 1 :(得分:0)
您可以在Objective-c中使用iPhone吗?
DWORD flags, reserved;
flags = reserved = 0;
if(!InternetGetConnectedState(&flags, reserved))
{
// No internet connection
} else {
// Have internet connection
}