更新plist的一部分

时间:2012-03-27 07:18:11

标签: iphone objective-c ios cocoa-touch plist

我有一个充满地点的plist。我有地址,没有纬度或经度。我希望应用程序在用户想要查看位置的详细信息时进行地理编码。但是,我还希望应用程序将纬度和经度写回plist,以便下次我可以跳过地理编码。有没有办法在plist中只写两个值? plist位于文档目录中。

非常感谢任何帮助或示例项目参考

利奥

1 个答案:

答案 0 :(得分:0)

NSDictionary有方法可以将其内容读/写到plist:

NSString* filePath = @""; // set file path here
NSMutableDictionary* pListValues = [[NSMutableDictionary alloc] initWithContentsOfFile:filePath];

// modify pListValues here

BOOL success = [pListValues writeToFile:filePath atomically:YES];
[pListValues release];