iOS 将json文件转为plist文件
程序员文章站
2022-04-12 22:02:20
ios 将json文件转为plist文件。
nsstring *path = [[nsbundle mainbundle] pathforresource:@"address.jso...
ios 将json文件转为plist文件。
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];