您的位置:首页 > 其它

在Xcode项目中读取plist文件

2012-08-22 13:07 190 查看
plist(Property list) 文件即属性列表文件,类似于XML格式的一种配置文件,里面可保存序列化的对象。这种plist文件在Mac OS X及相关产品中常见到,下面是在Xcode中如果读取或写入plist文件的示例。


读取一般的plist文件

实践证明,方法1比较靠谱
方法1:// 取得文件路径...NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Shopping-Info"ofType:@"plist"];// 读取到一个NSDictionaryNSDictionary *dictionary = [[NSDictionary alloc] initWithContentsOfFile:plistPath];// 读取到一个NSArrayNSArray *array = [[NSArray alloc] initWithContentsOfFile:plistPath];...


读取项目主配置文件xxx-Info.plist或Info.plist

方法2:...NSDictionary *dict = [[NSBundle mainBundle] infoDictionary];NSString *URLString = [dict objectForKey:@"Bundle version"];...
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: