本地json获得
NSString *jsonPath = [[NSBundle mainBundle] pathForResource:@"LocList" ofType:@"json"];
NSData *data=[NSData dataWithContentsOfFile:jsonPath];
NSError *error;
id jsonObject=[NSJSONSerialization JSONObjectWithData:data
options:NSJSONReadingAllowFragments
error:&error];
NSLog(@"%@",jsonObject);
本地plist文件获得
self.DashuArray =[NSMutableArray arrayWithCapacity:0];
NSBundle *bundle = [NSBundle mainBundle];
// 利用mainBundle 获得plist文件在主资源包中的全路径
NSString *file = [bundle pathForResource:@"LocList" ofType:@"plist"];
// 凡是参数名为File,传递的都是文件的全路径
self.DashuArray = [NSMutableArray arrayWithContentsOfFile:file];
NSLog(@"%@",self.DashuArray);
网友评论