iOSアプリでインターネット接続をテストするメソッドを実装しました。問題は、携帯電話ではなく、wifi経由でインターネット接続をテストする方法だけが欲しいということです。それ、どうやったら出来るの?:-)PS私は最新バージョンのXcodeとiOS6を使用しています。
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];
}