1
GhXst OP 没有人帮忙吗?还是我提供的信息不够全啊?
|
2
GhXst OP 好了,已经解决了,写文件成功,就是有些乱码,再调整了
[NSKeyedArchiver archiveRootObject:self.data toFile:fileName]; |
3
Livid MOD NSMutableArray 有 writeToFile:atomically: 这个方法么?
|
4
keakon 2011-11-30 00:00:35 +08:00
@GhXst 乱码和coder有关,只要你载入没问题,就不用管乱码了。拼接路径可以用stringByAppendingPathComponent:。
|
5
GhXst OP @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> |