JSON解析
NSString *path = [[NSBundle mainBundle] pathForResource:@"activitylist" ofType:@"txt"];
NSData *data = [NSData dataWithContentsOfFile:path];
NSMutableDictionary *dic = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
使用本地文件
1.找到文件的路径
NSString *path = [[NSBundle mainBundle]pathForResource:@"0825Student" ofType:@"plist"];
self.stuArr = [NSMutableArray array];
2.读取本地数据
self.stuArr = [NSMutableArray arrayWithContentsOfFile:path];
本文介绍了如何使用Objective-C进行JSON解析及本地文件读取,包括路径查找、数据读取和JSON转换等关键步骤。

被折叠的 条评论
为什么被折叠?



