获取沙盒目录

⭐️沙盒路径:###

NSLog(@"%@", NSHomeDirectory()); //打印沙盒路径

/Users/xxx/Library/Developer/CoreSimulator/Devices/CAB20F2D-FAD5-4393-935E-2AC74E1469F6/data/Containers/Data/Application/3E3E09B1-FA9C-4881-BDBC-677293C6477C

获取沙盒目录_第1张图片
Snip20170622_4.png

⭐️打开沙盒目录:###

获取沙盒目录_第2张图片
Snip20170622_5.png

⭐️各目录的作用分析:###

Snip20170524_2.png

⭐️获取沙盒内各个文件夹的路径:###

//Libriay/Preferences (偏好设置)
NSUserDefaults * preference = [NSUserDefaults standardUserDefaults];
[preference setObject:@"MM" forKey:kAccount];
[preference setObject:@"123" forKey:kPwd];
     
//沙盒内Document文件夹,运行时数据,会备份
NSLog(@"%@", NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]);
     
//Libriay/Caches,运行时缓存,不会备份,不会被系统删掉,一般存储体积不大的非重要数据
NSLog(@"%@", NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0]);
     
//沙盒内Temp文件夹,运行完毕后会被系统删掉
NSLog(@"%@", NSTemporaryDirectory());

你可能感兴趣的:(获取沙盒目录)