更改Plist中的数据 [英] Changing Data in a Plist
本文介绍了更改Plist中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿,好吧,我有一个看起来像.plist的
Hey, alright so I have a .plist that looks like;
<plist version="1.0">
<dict>
<key>Item 0</key>
<dict>
<key>Name</key>
<string>Jero</string>
<key>Initiative</key>
<integer>0</integer>
<key>EditThis</key>
<false/>
</dict>
</dict>
</plist>
在该应用我有它,以便当选择的行中的一个(数据被放在一个UITableView)它推到一个新的视图控制器.我还想将'EditThis'布尔值设置为yes,以便编辑视图控制器可以学习要编辑的内容.但是,我似乎无法弄清楚如何更改该值.非常感谢您的帮助.
In the app I have it so that when one of the rows (The data is put in a UITableView) is selected it pushes to a new view controller. I would like also to set the 'EditThis' boolean to yes, so the edit view controller can learn which to edit. However I can't seem to figure out how to change the value. Any help is much appreciated.
推荐答案
将plist加载到可变字典中:
Load the plist into a mutable dictionary:
NSMutableDictionary *plist = [NSMutableDictionary dictionaryWithContentsOfFile:@"file.plist"];
[plist setObject:[NSNumber numberWithBool:YES] forKey:@"EditThis"];
[plist writeToFile:@"file.plist" atomically:YES];
这篇关于更改Plist中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文