#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)
最新推荐文章于 2024-03-21 08:19:42 发布
本文详细介绍了iOS应用的沙盒环境,包括Documents、Library、tmp等目录的作用和使用场景,以及如何获取这些沙盒路径的方法,对于iOS开发者理解文件管理至关重要。
摘要由CSDN通过智能技术生成