我正在开发一个包含 5 个plist
文件的应用程序。我想将所有这些文件保存在文档目录中。因为我想动态地向它们添加数据。我正在使用创建一个 plist 路径
从中检索数据plist
NSMutableArray *pathsArray = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docpath = [pathsArray objectAtIndex:0];
NSString *scorePlistPath = [docpath stringByAppendingPathComponent:@"highScores.plist"];
if (![[NSFileManager defaultManager] fileExistsAtPath:scorePlistPath]) {
scorePlistPath = [[NSBundle mainBundle] pathForResource:@"highScores" ofType:@"plist"];
}
highScoreArray = [[NSMutableArray alloc]initWithContentsOfFile:scorePlistPath];
将数据写入plist
scorePlistPath = [docpath stringByAppendingPathComponent:@"highScores.plist"];
[highScoreArray writeToFile:scorePlistPath atomically:YES];
现在我想plists
在文档目录中再添加一个.. 不在 Bundle 中。我怎样才能做到这一点..?