1,文件保存策略
1.1单个文件持久性
1.2 多个文件持久性
优势:延迟加载用户数据
方便释放闲置的内存
缺点:增加了应用程序的复杂性
1.3持久保存应用程序数据
获取路径: //获取应用程序沙盒Document
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
//获取theFile.txt的完整路径
NSString *filename = [documentsDirectory stringByAppendingPathComponent:@"theFile.txt"];
NSLog(@"%@",documentsDirectory);
NSLog(@"%@",filename);
//获取tmp目录
NSString *tempPath = NSTemporaryDirectory();
NSString *tempFile = [tempPath stringByAppendingPathComponent:@"tempFle.txt"];
NSLog(@"%@",tempPath);
NSLog(@"%@",tempFile);