本地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"];
// 凡是參數(shù)名為File厚脉,傳遞的都是文件的全路徑
self.DashuArray = [NSMutableArray arrayWithContentsOfFile:file];
NSLog(@"%@",self.DashuArray);