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);
ios取沙盒(sandbox)中的路径,布布扣,bubuko.com
原文:http://www.cnblogs.com/liyang31tg/p/3633472.html