我正在尝试设置一种在给定文件路径创建 .plist 文件的方法,但是我当前的代码仅适用于修改 plist。有没有简单的方法来创建 plist 文件?这只是该方法的初稿,最终版本将采用 course_title 变量。谢谢
- (void)writeToPlist{
NSString *filePath = [NSString stringWithFormat:@"%@/course_title", DOCUMENTS_FOLDER];
NSMutableDictionary* plistDict = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];
[plistDict setValue:@"1.1.1" forKey:@"ProductVersion"];
[plistDict writeToFile:filePath atomically: YES];
}
感谢您的代码,地址为 http://www.ipodtouchfans.com/forums/showthread.php?t=64679
最佳答案
你只需使用初始化一个空字典
NSMutableDictionary* plistDict = [NSMutableDictionary dictionary];
而不是从文件中读取它。然后像以前一样继续。
关于iphone - 创建 plist iPhone SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2186978/