I need to write several line to a file. How can I move to the next line so that the file content is not overwritten each time? I am using a for loop with the following code in it
[anNSString writeToFile:path atomically:YES encoding:NSUTF8StringEncoding error:NULL];
The NSString. anNSString is reinitialized during each loop. SO i need to keep adding to the file path each during each loop.
Thanks
You just write it out all at once, rather than attempting to write it incrementally.
-[NSString writeToFile:atomically:encoding:error]will just overwrite the file each time – it does not append.Here’s an illustration: