How do I write a simple string to a file on the iphone?
iphone
Solution
If you have an `NSString`, you can do
NSString *myString; //Assuume the string you want to write is this
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"myfile.txt"];
[myString writeToFile:path atomically:YES];
Problem
Simple question: I have a large string that I want to write to a file in the docs folder for an app. How do I do a simple file creation/write?