我有一个方法实现了测试我的 iOS 应用程序中的互联网连接。问题是,我只想要通过 wifi 测试互联网连接的方法,而不是蜂窝网络。我怎么做?:-) PS 我正在使用最新版本的 Xcode 和 iOS 6。
NSURL *scriptUrl = [NSURL URLWithString:@"http://10.247.245.87/stores/test.html"];
NSData *data = [NSData dataWithContentsOfURL:scriptUrl];
if (data != nil){
UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @"Success"
message: @"You're connected to the server"
delegate: self
cancelButtonTitle: @"Close"
otherButtonTitles:nil];
//Show Alert On The View
[alert show];
}
else {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle: @"Connection Failed"
message: @"Please connect to network and try again"
delegate: self
cancelButtonTitle: @"Close"
otherButtonTitles:nil];
//Show Alert On The View
[alert show];
}