有時開發過程當中,常常須要調試接口,可是可能常常沒有網絡,致使調試沒法正常進行。json
對此能夠本身手動設置一些假數據,也能夠經過計算機來爲咱們保存一份真實的網絡數據,並本身轉化成plist數據,存在本地使用。網絡
## 直接在Mac上運行post
```objcatom
NSString *path = @"/Users/xiaoyou/Desktop/lot.json"; spa
NSArray *array = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:path] options:NSJSONReadingMutableLeaves error:nil]; 調試
[array writeToFile:@"/Users/xiaoyou/Desktop/lot.plist"atomically:YES]; orm
```blog
## 直接在模擬器上運行接口
```objc開發
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];
```