メイクGETまたはiOSアプリからのPOSTリクエスト
例:
NSURL *url = [NSURL URLWithString:@"http://www.site.com/sendData.php"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestReloadIgnoringCacheData
timeoutInterval:60];
[theRequest setHTTPMethod:@"POST"];
[theRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
NSString *postData = [NSString stringWithFormat:@"name1=%@&name2=%@", data1, data2];
NSString *length = [NSString stringWithFormat:@"%d", [postData length]];
[theRequest setValue:length forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPBody:[postData dataUsingEncoding:NSASCIIStringEncoding]];
NSURLConnection *sConnection = [NSURLConnection connectionWithRequest:theRequest delegate:self];
[sConnection start];
In order to download the contents of a URL, an application needs to provide a delegate object that, at a minimum, implements the following delegate methods: connection:didReceiveResponse:, connection:didReceiveData:, connection:didFailWithError: and connectionDidFinishLoading:.
about NSURLConnection about NSURLRequest
-1:いくつかのより多くの情報を追加してください – Paranaix