< iOS 数据持久化 >

iOS数据持久化 - Property List

2020-07-21  本文已影响0人  zhYx_

一.简介

二.用法

1.创建/修改Plist数据


工程目录中右键 > New Flie(快捷键Command+N) 选中Property List文件双击或点击Next 配置Plist信息(名称/储存位置等) 加号创建对象,左侧箭头朝下会向下级创建,箭头朝右会平级创建,Type设置对象类型(根目录只能是Arr或Dict类型)

2.读取/使用Plist数据

// 获取对应名称Plist的路径
NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"Property List" ofType:@"plist"];
// 传入路径取出Plist数据(注意:此处根据根目录的数据类型决定使用NSArray或NSDictionary)
NSArray *plistArr = [[NSArray alloc] initWithContentsOfFile:plistPath];
NSDictionary *plistDict = [[NSDictionary alloc] initWithContentsOfFile:plistPath];
上一篇 下一篇

猜你喜欢

热点阅读