Create a plist iPhone SDK
I am开发者_StackOverflow社区 trying to set up a method that creates a .plist file at a given file path, however my current code only works for modifying a plist. Is there an easy way to create the plist file? This is simply a first draft of the method, the final version will take a variable for the course_title. Thanks
- (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];
}
Thanks for the code goes to http://www.ipodtouchfans.com/forums/showthread.php?t=64679
You just init an empty dictionary using
NSMutableDictionary* plistDict = [NSMutableDictionary dictionary];
instead of reading it from the file. Then you proceed as before.
精彩评论