iPhone: Does http supports Asynchronous method?
<p>I am developing an application for iOS 4.x devices. I am implementing a communication module, where-in program sends file(some times multiple files at a time) to the server periodically. I am implementing code using the following function. I would like to know, does Apple's http code like below supports "Asynchronous" method (or) Should i have to use some third party API's like "ASIHTTPRequest" to support Asynchronous call in my function. Please advise.</p>

<pre><code>-(void) HttpUpload : (UIImage *) image :(NSString *) fileNameStr
</code></pre>

<p>{</p>

<pre><code>NSData *imageData = UIImageJPEGRepresentation (image, 90);
NSString *urlString = @"http://iphone.zcentric.com/test-upload.php";

NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];

// header now..
NSString *boundary = [NSString stringWithString:@"---------------------------14737809831466499882746641449"];
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
[request addValue:contentType forHTTPHeaderField: @"Content-Type"];

// Create body of the post..
NSMutableData *body = [NSMutableData data];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]]; 
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"userfile\"; filename=\"%@.jpg\"\r\n", fileNameStr] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[[NSString stringWithString:@"Content-Type: application/octet-stream\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[NSData dataWithData:imageData]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n",boundary] dataUsingEncoding:NSUTF8StringEncoding]];

[request setHTTPBody:body];

// lets make the connection to the web
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *responseString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];

NSLog(responseString);
</code></pre>

<p>}</p>

<p>Thank you!</p>
