서버에서 데이터를 가져 오는 데 문제가 있습니다. 서버가 내 로컬 호스트입니다. 로컬 호스트에서버 objective-c에서 데이터 가져 오기
SMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"localhost"] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
[request setHTTPBody:[NSString stringWithFormat:@"test.php"]];
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
if (connection)
{
NSLog(@"NSURLConnection connection==true");
NSURLResponse *response;
NSError *err;
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&err];
NSLog(@"responseData: %@", responseData);
}
else
{
NSLog(@"NSURLConnection connection==false");
};
나는 간단한 PHP 스크립트라는 test.php이 : 나는 사파리에서 로컬 호스트/test.php를 열고있어 경우
<?php
echo "It works!!!"
?>
내가 볼 수있는 "그것은 작동을!"
무엇이 문제입니까? –
있는 NSURLConnection 연결 == 진정한 드 responseData : (널) – Oleg