ios取沙盒(sandbox)中的路径

NSString * str=  NSHomeDirectory();//取得当前应用在硬盘上得位置/一直到了hash码,ios中hash码代表一个应用
NSLog(@"%@",str);
str= [[NSBundle mainBundle]bundlePath];//一直到了hash码下面的.app文件//这个就是编译好的2进制程序
NSLog(@"%@",str);
str= [[NSBundle mainBundle]pathForResource:@"1" ofType:@".png"];//返回的就是沙盒中的资源路径
NSLog(@"%@",str);
str=  [[NSBundle mainBundle]pathForResource:@"1.png" ofType:nil inDirectory:@"images"];//后面这个文件夹表示的如果是引用的一个路径就需要,就是copy一个图片到项目中用的是引用,不是真的copy进来
NSLog(@"%@",str);
NSArray *arry1=NSSearchPathForDirectoriesInDomains(NSDesktopDirectory, NSUserDomainMask,YES);//在这个应用下找任何路径都可以
str =  [arry1 objectAtIndex:0];
NSLog(@"%@",str);
1.这里只记录一些学习笔记 2.这里只记录一些学习心得,如果心得方向有错,请留言 2.这里只记录一些日记(只为提升英语,暂时有点忙,等转行了开始写)
原文地址:https://www.cnblogs.com/liyang31tg/p/3633472.html