iOS 将json文件转为plist文件

2017-08-04  本文已影响82人  JohnayXiao
 NSString *path = [[NSBundle mainBundle] pathForResource:@"address.json" ofType:nil];
    NSLog(@"path = %@",path);
    
    NSArray *array = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:path] options:NSJSONReadingMutableLeaves error:nil];
    
    NSString *newPath = [NSString stringWithFormat:@"%@%@",[[NSBundle mainBundle] bundlePath],@"/address.plist" ];
    NSLog(@"newPath = %@", newPath);
    
    [array writeToFile:newPath atomically:YES];

上一篇 下一篇

猜你喜欢

热点阅读