0

To append a simple string key-value pair, we do this in object C

   NSMutableData *body = [NSMutableData data];
[body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\";\r\n\r\n%@", _name, _value] dataUsingEncoding:NSUTF8StringEncoding]];

However, how do we append NSArray of data. Let's say Email Array contains={tom@yahoo.com, dve@yahoo.com, john@yahoo.com}

How do we append Email array to the NSMutableData body?

jason white
  • 687
  • 4
  • 11
  • 28

1 Answers1

1

you can turn your array into NSString as you did with single string:

NSArray array = [[NSArray alloc] init];
...
[body appendData:[[NSString stringWithFormat:@"%@", array] dataUsingEncoding:NSUTF8StringEncoding]];

but I recommend to use NSKeyedArchiver, see this topic

Community
  • 1
  • 1
medvedNick
  • 4,512
  • 4
  • 32
  • 50