To read the file from the bundle do the following
NSString *dataFile = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"txt"];
To read it from your sandbox storage (documents)
NSString *docPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/YourFile.txt"];
NSString *dataFile = [NSString stringWithContentsOfFile:docPath
usedEncoding:NSUTF8StringEncoding
error:NULL];
To write to document folder
NSString *docPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/YourFile.txt"];
[dataFile writeToFile:docPath
atomically:YES
encoding:NSUTF8StringEncoding
error:NULL];
Please note you will not be able to write the file in the bundle folder of your application
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…