iOS開発用のJSONからPLIST(json形式で保存されたファイルをplistファイルに変換します)
Json Plist Ios Development
開発インターフェイスでデバッグインターフェイスが必要になることがよくありますが、ネットワークがないことが多く、デバッグが失敗する可能性があります。
偽のデータを自分で手動で設定することも、実際のネットワークデータをコンピューターに保存して、ローカルで使用するためにplistデータに変換することもできます。
Macで直接実行する
NSString *path = @'/Users/xiaoyou/Desktop/lot.json' NSArray *array = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:path] options:NSJSONReadingMutableLeaves error:nil] [array writeToFile:@'/Users/xiaoyou/Desktop/lot.plist' atomically:YES]
シミュレーターで直接実行する
NSString *path = [[NSBundle mainBundle] pathForResource:@'lot.json' ofType:nil] NSArray *array = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:path] options:NSJSONReadingMutableLeaves error:nil] NSString *newPath = [NSString stringWithFormat:@'%@%@',[[NSBundle mainBundle] bundlePath],@'/lot.plist' ] [array writeToFile:newPath atomically:YES]