iOS 本地沙盒文件的存储修改与删除(以NSDictionary为例)
存储文件
+(void)saveJsonToDocument:(NSDictionary *)dic andName:(NSString *)name
{
//获取Documents路径
NSArray *array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documents = [array lastObject];
NSString *documnetPath = [documents stringByAppendingPathComponent:name];
NSData *data= [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil];
[data writeToFile:documnetPath atomically:YES];
}
读取文件
+(NSDictionary *)readJsonWithName:(NSString *)name
{
//获取Documents路径
NSArray *array = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documents = [array lastObject];
NSString *documnetPath = [docume