0

I want to send image with key in a NSMutableDictionary and send all other elements of dictionary to server using post & Nsurlsession in ios using objective C

Pratik
  • 103
  • 1
  • 9

1 Answers1

0

it's easy just convert UIImage to Data then set it in nsmutabledictionary

NSData *data = UIImageJPEGRepresentation(myImageView.image, 0.8);
Marwan Alqadi
  • 795
  • 8
  • 14
  • you should convert NSMutabledictionary to JSON String then to NSData like this : NSData *jsonData2 = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&error]; bodyRequest = [[NSString alloc] initWithData:jsonData2 encoding:NSUTF8StringEncoding]; NSData *postData = [bodyRequest dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]; [request setHTTPBody:postData]; – Marwan Alqadi Dec 20 '18 at 12:32