Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top