您好,欢迎来到二三娱乐。
搜索
您的当前位置:首页本地plist和josn解析

本地plist和josn解析

来源:二三娱乐

本地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);

Copyright © 2019- yule263.com 版权所有 湘ICP备2023023988号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务