一、一般本地可以存储轻量级数据存储 plist 这个主要是操作字典
方法如下:
NSString * sampleFile= [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"sections_auth=4.plist"];
NSDictionary* dic_sections = [NSDictionary dictionaryWithContentsOfFile:sampleFile];
二、有时候也可用json结构解析 这个就不限制了字典、数组都支持
方法如下:
NSString *sampleFile = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"file.json"];
NSString *jsonString = [NSString stringWithContentsOfFile:sampleFile encoding:NSUTF8StringEncoding error:nil];
NSDictionary * dic_sections = [jsonString objectFromJSONString];//即得到了file.json的全部内容
eg: file.json 内容如下
{
"data": [
[
"暂无"
],
[
"资料001",
"资料002",
"资料003"
],
[
"资料001"
],
[
"资料001",
"资料002",
"资料003",
"资料004"
]
],
"head": [
"保密责任",
"合同",
"企业资料",
"培训资料"
]
}