NSString:writeToFile: method takes four arguments; filename, atomic or not, encoding, error code. Nothing difficult in this code, enjoy!
Example - [NSString writeToFile]
-(void) writeToTextFile {
// Document 디렉토리.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
// 데이터를 저장할 파일명 생성.
NSString *fileName = [NSString stringWithFormat:@"%@/textFile.txt", documentsDirectory];
// 파일의 내용 생성.
NSString *content = @"One\nTwo\nThree\nFour\nFive";
// Document 디렉토리에 저장.
[content writeToFile:fileName
atomically:NO
encoding:NSStringEncodingConversionAllowLossy
error:nil];
}