こんにちは私はiOS用のobjective-cでプログラムを作成しています。SMTPサーバー(@の後)が存在するかどうかを確認するには、pingまたはHTTPリクエストを実行して、ステータス(200)を返します。
私が今していることは、UITextField.textを取得し、それを切り取り、@の後に部分文字列を取得し、これを実行することです...しかし、それは機能していません...
NSError *error = nil;
NSURL *url = [NSURL URLWithString:@"gmail.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];;
NSURLResponse *response = nil;
NSData *data=[[NSData alloc] initWithData:[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]];
NSString* retVal = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
// you can use retVal , ignore if you don't need.
NSInteger httpStatus = [((NSHTTPURLResponse *)response) statusCode];
NSLog(@"responsecode: %d", httpStatus);
// there will be various HTTP response code (status)
// you might concern with 404
if(httpStatus == 200)
{
NSLog(@"FEELIX CONTENT");
// do your job
}
else
{
NSLog(@"FOCK!");
}