zoukankan      html  css  js  c++  java
  • iOS-本地沙盒路径

    沙盒几个路径:

    沙盒里的文件夹包括Documents、Library、tmp。这三个文件夹的作用请点击这里。接下来我们来讲解如何获取Documents、Library、tmp的路径。

    获取沙盒根目录

    获取沙盒根目录,直接调用NSHomeDirectory():

    //获取沙盒根目录

    NSString*directory=NSHomeDirectory();

    NSLog(@"directory:%@",directory);

    1.获取Documents路径

    获取Documents路径如下:

    //获取Documents路径

    NSArray*paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);

    NSString*path=[pathsobjectAtIndex:0];

    NSLog(@"path:%@",path);

    获取Documents文件夹目录,第一个参数是说明获取Doucments文件夹目录,第二个参数说明是在当前应用沙盒中获取。  

    2.获取Library路径

    //获取Library路径

    NSArray*paths=NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,NSUserDomainMask,YES);

    NSString*path=[pathsobjectAtIndex:0];

    NSLog(@"path:%@",path);

    3.获取Caches路径

    //获取Caches路径

    NSArray*paths=NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,YES);

    NSString*path=[pathsobjectAtIndex:0];

    NSLog(@"path:%@",path);

    4.获取tmp路径

    NSString*tmp=NSTemporaryDirectory();

    NSLog(@"tmp:%@",tmp);

  • 相关阅读:
    Finding Palindromes POJ
    吉哥系列故事——完美队形II HDU
    Period II FZU
    生日礼物&&Supermarket
    炮兵阵地[状态压缩DP]
    最小表示法 P1368
    Period
    最长异或路径
    Luogu P5490 扫描线
    解方程
  • 原文地址:https://www.cnblogs.com/shenyangxiaohuo/p/5229243.html
Copyright © 2011-2022 走看看