我正在创建一个允许您记录棋盘游戏的应用程序。我将我的日志存储在一个 plist 中,我试图弄清楚如何附加 plist。我想我理解逻辑,但我无法将其放入代码中。
我的 plist 看起来像这样:
现在我正在尝试这样的事情,但我相信它只会覆盖 plist 文件而不是附加
//get path for root directory
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSLog(@"paths: %@",paths);
//get path for documents directory
NSString *documentsPath = [paths objectAtIndex:0];
NSLog(@"documentsPath: %@",documentsPath);
//get the path for logs.plist file
NSString *plistPath = [documentsPath stringByAppendingPathComponent:@"logs.plist"];
//create dictionary with values
NSDictionary *plistDict = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:myLogTitle, name, players, myNotes, nil] forKeys:[NSArray arrayWithObjects:@"Log Title",@"Name",@"Players","Notes", nil]];
//write out data
[plistDict writeToFile:plistPath atomically:YES];
任何帮助将非常感激。