#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//获取家目录,也就是根目录
NSString * homePath=NSHomeDirectory();
NSLog(@"家目录:%@",homePath);
//获取DocuMents路径
NSArray * pathArr1=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString * docuPath=[pathArr1 objectAtIndex:0];
NSLog(@"DocuMents路径:%@",docuPath);
//Library路径
NSArray * pathArr2=NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString * libPath=[pathArr2 objectAtIndex:0];
NSLog(@"Library路径:%@",libPath);
//获取tmp路径
NSString * tmpPath=NSTemporaryDirectory();
NSLog(@"temp的路径:%@",tmpPath);
//获取Library下的cachPath路径
NSArray * pathArr3=NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString * cachPath=pathArr3[0];
NSLog(@"cachPath路径:%@",cachPath);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
沙盒路径(OC)
最新推荐文章于 2026-05-16 09:08:14 发布
本文详细介绍了iOS应用的沙盒环境,包括Documents、Library、tmp等目录的作用和使用场景,以及如何获取这些沙盒路径的方法,对于iOS开发者理解文件管理至关重要。
&spm=1001.2101.3001.5002&articleId=74255346&d=1&t=3&u=5a4588debb684cecbe23ee7cd0495509)
1041

被折叠的 条评论
为什么被折叠?



