I’m trying to use the stringWithString: and stringWithContentsOfFile to save a string to a file and then read it back. It seemed like it should be very simple, but the object return by stringWithContentsOfFile is a null
code
// test strings
NSString *s=[ NSString stringWithString:@"hi"];
[ s writeToFile:@"test.txt" atomically:TRUE];
NSString *g=[ NSString stringWithContentsOfFile:@"test.txt"];
With your code, it will try to save the test.txt file in the root directory, and we can’t have access to the root directory. The only way to save a file is to write it on the application document directory :