ios沙盒查找图片展示
iOS如何找到自己的沙盒
在ios开发我们会用到沙盒,由于自己对沙盒理解的不够,所以找不到沙盒文件在哪里,当然要知道路径了
例如我的路径
NSString* cachepath = [NSHomeDirectory()stringByAppendingString:@"Douments"]; NSLog(@"%@",cachepath);
运行以后就可以看到路径是在哪里,并且知道是哪个文件,下面是打印出来的路径,我们可以根据这个来找
/Users/rjxyrjxy/Library/Application Support/iPhone Simulator/7.0.3/Applications/D7258B1F-D328-4FEB-8593-32D916E03748Douments
具体的寻找路径,如下
同时附上获取沙盒目录的代码
沙盒文件目录获取代码:
//Home目录
1
|
<code class = "hljs" >NSString *homeDirectory = NSHomeDirectory();</code> |
//Document目录
1
2
|
<code class = "hljs" >NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *path = [paths objectAtIndex: 0 ];</code> |
//Cache目录
1
2
|
<code class = "hljs" >NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); NSString *path = [paths objectAtIndex: 0 ]; </code> |
//Libaray目录
1
2
|
<code class = "hljs" >NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); NSString *path = [paths objectAtIndex: 0 ];</code> |