我想知道如何在同一个 NSMutableRequest 中上传图像和一些数据
- (void)startAsyncRequest
{
// Setting of the request
NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:self.url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0];
[urlRequest setHTTPMethod:self.method];
[urlRequest setHTTPBody:data];
// Send the request
NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
if (connection) {
// Connection succeded
self.receiveData = [NSMutableData data];
} else {
// Connection Failed
self.error = @"Connection Failed";
// Inform the user that the connection failed
[self.delegate requestFailed:self];
}
}