我有这样的json文件:
{"fileContent":[{"name":"aaaa","type":"file","ext":"sql","modified":"2013\/04\/11 - 04:29","created":"2013\/04\/11 - 04:29","size":"1460","dirid":"5"}, {"name":"directory02","type":"file","ext":"sql","modified":"2013\/04\/11 - 04:29","created":"2013\/04\/11 - 04:29","size":"1577","dirid":"6"}, {"name":"index2","type":"file","ext":"php","modified":"2013\/04\/11 - 05:06","created":"2013\/04\/11 - 05:06","size":"9932","dirid":"8"}, {"name":"directorffdsgfg","type":"file","ext":"sql","modified":"2013\/04\/11 - 10:00","created":"2013\/04\/11 - 10:00","size":"1577","dirid":"10"}, {"name":"directory02","type":"file","ext":"sql","modified":"2013\/04\/11 - 12:10","created":"2013\/04\/11 - 12:10","size":"1577","dirid":"11"},{"name":"jquery- mousewheel-master","type":"file","ext":"zip","modified":"2013\/04\/11 - 12:10","created":"2013\/04\/11 - 12:10","size":"5213","dirid":"12"},{"name":"perfect-scrollbar-master","type":"file","ext":"zip","modified":"2013\/04\/11 - 12:10","created":"2013\/04\/11 - 12:10","size":"11867","dirid":"13"}, {"name":"E_PDF","type":"file","ext":"png","modified":"2013\/04\/17 - 09:15","created":"2013\/04\/17 - 09:15","size":"7467","dirid":"24"}, {"name":"filefolder_H.PNG","type":"file","ext":"png","modified":"2013\/04\/17 - 09:15","created":"2013\/04\/17 - 09:15","size":"10575","dirid":"25"}],"folderContent": [{"name":"Folder 2","type":"folder","ext":"sql","modified":"2013\/04\/11 - 05:04","created":"2013\/04\/11 - 05:04","size":"1577","dirid":"7"},{"name":"Folder 1","type":"folder","ext":"zip","modified":"2013\/04\/15 - 09:08","created":"2013\/04\/15 - 09:08","size":"11867","dirid":"14"}],"files":9,"folders":2}
并将其NSDictionary
与名称标题一起存储。(向下代码显示它:)
NSDictionary *titles = [NSJSONSerialization JSONObjectWithData:Data options:kNilOptions error:nil];
我从标题中读取 fileContent 值并将它们存储在 NSMutableArray 中,名称为“all”,如下代码:
NSArray *fileContent = [titles objectForKey:@"fileContent"];
NSMutableArray *all = [[NSMutableArray alloc]init];
[all addObjectsFromArray:fileContent];
我想在文件中存储“全部”中的 2 个值(名称和类型),.plist
但我不知道该怎么做?