Tips:沙盒目录和访问方法
2017-11-03 本文已影响0人
dc630f46ee2d
前言
老是忘记沙盒目录和访问方法,写了个demo和流程图做为复习
demo
- (void)viewDidLoad {
[super viewDidLoad];
// 沙盒目录
NSString *home = NSHomeDirectory();
// 沙盒下document目录
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDir = [paths objectAtIndex:0];
//沙盒下library/Caches
NSArray *paths1 = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
NSString *cachesDir = [paths1 objectAtIndex:0];
//沙盒下tmp 目录
NSString *tmp = NSTemporaryDirectory();
// library/prefrence目录下保存一个plist文件,是NSUserDefaults用来实现磁盘缓存的文件
[[NSUserDefaults standardUserDefaults] setObject:@"zhouming" forKey:@"name"];
[[NSUserDefaults standardUserDefaults] synchronize];
}