문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top