Iterate through the array, and write the parts you wish to, to a string.
A string with commas in will help considerably. Carriages returns are good too.
When the string is done. Write it to a file.
NSMutableString *target = [@"head1,head2,head3\n" mutableCopy];
for (NSDictionary *dict in array) {
[target appendFormat:@"%@,%@,%@\n",dict[@"thing"],dict[@"otherthing"],dict[@"lemming"]];
}
NSError *error = NULL;
BOOL success = [target writeToURL:somewhere atomically:YES encoding:NSUTF8StringEncoding error:&error];
if (!success) {
NSLog(@"oh no! - %@",error.localizedDescription);
}
The snippet assumes you have an array of NSDictionary
but in case its something else the principle is the same.
For each object print out a comma separated string and terminate with a CR.
Things you will have to guard against in real world data are
- descriptions with a comma in already.
- descriptions with a CR in already.