开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜