Add line breaks when changing array to json data
I want to convert my mutable array to JSON data. I have all ready done
this using
NSData *data = [NSJSONSerialization dataWithObject:myMutableArray
option:kNilOptions error:&error];
Later, I write the JSON to a .txt file, but it came as a clump of text
instead of each object in my array having a separate line when I emailed
it to myself and opened it. I added objects to my array by using the
following code:
for (int i=0; i < anotherArray; i++) {
NSSrring *s = [anotherArray objectAtIndex:i];
if ([s isEqualToString:anotherString] {
[myMutableArray addObject:s];
[myMutableArray addObject:@" "];
}}
I added the extra space to the array because I wanted the text file format
to be similar to this:
aString
anotherString
. . . .
what would I add to my array or JSON data to add the line breaks after
every line?
No comments:
Post a Comment