Как я могу загрузить файл и другой параметр, используя NSURLConnection

я используюNSURLConnection отправить те же данные (NSString) к серверу, и я хотел бы добавить с ними изображение или файл, так какова ценность типа контента?

Encoding
- (NSData *)encodingData:(NSMutableDictionary *)dictionary
{
    NSMutableArray *arrayPosts = [[NSMutableArray alloc] init];
    [dictionary enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
         NSString *encodedKey = [key stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
         NSString *encodedValue = [obj stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [arrayPosts addObject:[NSString stringWithFormat:@"%@=%@",encodedKey,encodedValue]];
    }];
    NSString *encodedArrayPosts = [arrayPosts componentsJoinedByString:@"&"];
    return [encodedArrayPosts dataUsingEncoding:NSUTF8StringEncoding];
}
Send Data
- (void)startAsyncRequest
{
   // Enable the network activity indicator in the status bar
   [self enableActivityIndicatorInStatusBar];

   // Setting of the request
   NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:self.url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0];
   [urlRequest setHTTPMethod:self.method];
   [urlRequest setHTTPBody:[self encodingData:self.dictionaryPosts]];

   // 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];
   }
}

Ответы на вопрос(1)

Ваш ответ на вопрос