@
keakon 想不到一个小小的问题惊动老大了!测试如下:
paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
documentsDirectory = [paths objectAtIndex:0];
fileName = [NSString stringWithFormat:@"%@/File.txt", documentsDirectory];
NSMutableArray* test = [[NSMutableArray alloc] init];
NSString* a = @"This is a test a!";
NSString* b = @"This is a test b!";
[test addObject:a];
[test addObject:b];
[test writeToFile:fileName atomically:YES];
输出文件成功,文件内容如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "
http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<string>This is a test a!</string>
<string>This is a test b!</string>
</array>
</plist>