本文介绍了如何以编程方式从plist添加和检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好所有
我是目标c的新手,我想动态/编程插入数据到plist.please帮助我。这是我的plist结构
hello all I am new to objective c and i want to insert data dynamically/programmatically into plist.please help me.Here is my plist structure
root
|_Client1
|_report1
|_application1
|_application2
|_report2
|_application3
|_Client2
|_report1
现在我想要动态添加和检索数据到我的plist中的application1,application2
请帮帮我
Now i want to add and retrieve data dynamically to application1,application2 in my plistplease help me
推荐答案
阅读内容.plist文件..
NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"league" ofType:@"plist"];
contentArray = [NSArray arrayWithContentsOfFile:plistPath];
写入.plist文件。
NSMutableDictionary * myDictionary;
NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"league" ofType:@"plist"];
[myDictionary writeToFile:plistPath atomically:YES];
请注意:
字典必须包含plist对象(实例) NSData
, NSDate
, NSNumber
, NSString
, NSArray
或 NSDictionary
)。字典键必须是 NSString
对象
Note that:Dictionary must contain plist objects (instances of NSData
, NSDate
, NSNumber
, NSString
, NSArray
, or NSDictionary
). And dictionary keys must be NSString
objects
这篇关于如何以编程方式从plist添加和检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!