//应用程序包中的资源路径获取方式
NSString *path=[[NSBundle mainBundle] pathForResource:@"iphone_skin" ofType:@"png"];
NSLog(@"%@",path);
//获取沙盒当中的路径获取方式
NSArray *paths=NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
NSLog(@"%@",[paths lastObject]);
//这种方式直接定位到了,Library 中的Documentatio中了
//这种方式,就定位到了,根目录下的,Docuemnts里面
NSLog(@"%@",[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"]);
模拟器下面的运行结果:
特别是地下的方法,看着有那么点,茴香豆的茴字有几种写法的意思,呵呵
2013-03-22 13:49:52.372 projectname[3379:11303] /Users/landeqiming/Library/Application Support/iPhone Simulator/6.0/Applications/DE4B7414-CA1F-4ABD-9049-68833268115D/CPL_OA.app/iphone_skin.png
2013-03-22 13:50:01.566 projectname[3379:11303] /Users/landeqiming/Library/Application Support/iPhone Simulator/6.0/Applications/DE4B7414-CA1F-4ABD-9049-68833268115D/Library/Documentation
2013-03-22 13:50:04.630 projectname[3379:11303] /Users/landeqiming/Library/Application Support/iPhone Simulator/6.0/Applications/DE4B7414-CA1F-4ABD-9049-68833268115D/Documents
2013-03-22 13:55:52.525 projectname[746:907] /var/mobile/Applications/53EA4F69-D41D-4A4C-B2B5-8F31EEAFE791/CPL_OA.app/iphone_skin.png
2013-03-22 13:55:59.601 projectname[746:907] /var/mobile/Applications/53EA4F69-D41D-4A4C-B2B5-8F31EEAFE791/Library/Documentation
2013-03-22 13:56:02.144 projectname[746:907] /var/mobile/Applications/53EA4F69-D41D-4A4C-B2B5-8F31EEAFE791/Documents
(lldb)