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);

相关文章:

  • 2021-04-18
  • 2022-01-20
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
  • 2022-01-30
猜你喜欢
  • 2021-03-31
  • 2021-12-19
  • 2021-12-31
  • 2021-06-22
  • 2022-12-23
相关资源
相似解决方案