I’m trying to write a csv file. I have two arrays at hand – one with the titles (Name, Number etc), another with the actual values (Jon, 123 …).
Now, after the following two operations:
[[titles componentsJoinedByString:@", "] writeToFile:file atomically:YES];
[[values componentsJoinedByString:@", "] writeToFile:file atomically:YES];
only the values array is written to the file. I realise that I may need to open the file again, but how do I do that after writing the first array? Or what is it exactly that I’m doing wrong if this is not the case?
Thanks!
The second line is in fact overwriting the file you wrote in the first line. One simple way to get around this problem would be to simply append the second string to the first (likely with an ‘\n’ in between since you’re making a csv file) and writing that string to your file: