//获取文本路径
NSString *filePath =[NSHomeDirectory() stringByAppendingPathComponent:@"Documents/newfile.txt"];
//准备文本内容
NSString *testString = @"文件内容";
//开始写入
[testString writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:nil];
// 写入完毕