处理文件 / 文本文件

NSString *text = @"Line 1\nLine 2";

NSError *error;
BOOL ok = [text writeToFile:@"file.txt"
    atomically:NO
    encoding:NSUTF8StringEncoding
    error:&error];

if (!ok) {
    NSLog(@"%@",
        error.localizedDescription);
}