IOS开发资料大全

iOS开发应用程序沙盒

2016-03-30  本文已影响76人  LennonLin

应用程序沙盒(App Sandbox,也称沙箱)

屏幕快照 2017-07-31 16.34.27.png

所以我们只要bundleId一致, 就会直接覆盖那个App

屏幕快照 2017-07-31 16.40.03.png

现在还疑惑项目下多了一个:项目名+.entiliements文件吗?

沙盒下的目录

NSString *path = NSHomeDirectory();
NSLog(@"path = %@", path);
屏幕快照 2017-07-31 16.51.37.png 屏幕快照 2017-07-31 16.53.36.png

Documents疑问和测试

    _responseObject = [NSMutableDictionary dictionary];
    for (NSInteger i = 0; i < 100; i++) {
        [_responseObject setObject:[NSString stringWithFormat:@"test %ld",i] forKey:[NSString stringWithFormat:@"test %ld",i] ];
    }
    // 是路径也是存储的键
    NSString *filePath = @"responseObject";
    // 存储数据
    [LXKArchiverTool archiverObject:_responseObject key:filePath filePath:filePath];

屏幕快照 2017-07-31 17.16.17.png
    // 是路径也是存储的键
   NSString *filePath = @"responseObject";
   
   // 存储数据
//    [LXKArchiverTool archiverObject:_responseObject key:filePath filePath:filePath];
   // 读取数据
    id object = [LXKArchiverTool unarchiverPath:filePath key:filePath];

屏幕快照 2017-07-31 17.18.34.png

Library

preference

NSUserDefaults *userDef = [NSUserDefaults standardUserDefaults];
   [userDef setObject:@"test" forKey:@"test"];
   [userDef synchronize];
屏幕快照 2017-07-31 17.36.38.png

caches

屏幕快照 2017-07-31 17.54.53.png

几个目录获取

// 沙盒路径
NSString * path = NSHomeDirectory()
NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSArray *paths1 = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSArray *paths2 = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
preference

-tmp:

//temp路径
NSString * tmpDir = NSTemporaryDirectory();

总结

上一篇下一篇

猜你喜欢

热点阅读