私のアプリでは、いくつかのデータをダウンロードして投稿する必要があります...まず、いくつかのデータをダウンロードしてから、投稿リクエストを行う必要があります。アプリのUIをフリーズしないように非同期リクエストを使用しています...しかし、メソッドを呼び出してデータを投稿するとき...サーバーから返されるデータは気にしません。ただし、このメソッドは、POSTリクエストを実行するときにも呼び出されます。
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)aResponse
{
NSLog(@"------------------------------- connectionDidReceiveResponse");
expectedResponseLength = [NSNumber numberWithFloat:[aResponse expectedContentLength]];
URLresponse = aResponse;
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
[self.responseData appendData:data];
}
この2つの方法(上)(情報をダウンロードするときに使用)を呼び出さずに、ユーザーGUIをフリーズせずに(自動)このような投稿リクエストを行うにはどうすればよいですか(投稿リクエストを行うときにデータを気にしませんが、データが必要です最初のケース)?
私の投稿リクエストはこれです:
- (void)postRequestWithURLState:(NSString *)url
{
NSString *bodyRequest = nil;
NSURL *requestURL = [NSURL URLWithString:url];
NSMutableURLRequest *theRequest = [[NSMutableURLRequest alloc] init];
//NSLog(@"-------------- bodyRequest: %@", bodyRequest);
[theRequest setURL:requestURL];
[theRequest setTimeoutInterval:2.0];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[bodyRequest dataUsingEncoding:NSASCIIStringEncoding]];
[self.oauthAuthentication authorizeRequest:theRequest];
NSURLConnection *conn = [NSURLConnection connectionWithRequest:theRequest delegate:self];
self.web = conn;
}