サーバーからデータを取得する-同期
NSURLConnectionを使ってサーバーからデータを取得することができます。
//URLを作成 NSURL* url; NSURLRequest* request; url = [NSURL URLWithString:@"http://www.iphonesdk-wiki.com"]; request = [NSURLRequest requestWithURL:url]; [request setHTTPMethod:@"GET"]; //リクエストしてデータを取得 NSData *dataReplay; NSString *stringReplay; NSURLResponse *response; NSError *error; dataReplay = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; //utf8データとして取得 stringReplay = [[NSString alloc] initWithData:dataReplay encoding:NSUTF8StringEncoding];