- 模拟器的路径
/contents/developer/platforms/iphoneos.platform/devicesupport
- 获取沙盒根目录路径
NSString*homeDir = NSHomeDirectory();
- 获取Documents目录路径
NSString*docDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES) firstObject];
- 获取Library的目录路径
NSString*libDir = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,NSUserDomainMask,YES) lastObject];
- 获取cache目录路径
NSString*cachesDir = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,YES) firstObject];
// directory:搜索文件夹
// domainMask:在哪个范围内搜索 NSUserDomainMask:在用户中查找
// expandTilde: YES :在路径展开 NO:不展开路径 ~:代替沙盒路径
- 获取tmp目录路径
NSString*tmpDir =NSTemporaryDirectory();
- 获取工程路径
NSLog(@"%@",[[NSBundle mainBundle] bundlePath]);
- 获取工程目录下的文件路径
NSString*imagePath = [[NSBundle mainBundle] pathForResource:@"apple" ofType:@"png"];
UIImage*appleImage = [[UIImage alloc] initWithContentsOfFile:imagePath];
网友评论