iOS中的沙盒机制
来源:互联网 发布:2017淘宝网红店排名 编辑:程序博客网 时间:2024/06/06 04:25
IOS中的沙盒机制(SandBox)是一种安全体系,它规定了应用程序只能在为该应用创建的文件夹内读取文件,不可以访问其他地方的内容。所有的非代码文件都保存在这个地方,比如图片、声音、属性列表和文本文件等。
1.每个应用程序都在自己的沙盒内
2.不能随意跨越自己的沙盒去访问别的应用程序沙盒的内容
3.应用程序向外请求或接收数据都需要经过权限认证
查看模拟器的沙盒文件夹在Mac电脑上的存储位置,首先,这个文件夹是被隐藏的,所以要先将这些文件显示出来,打开命令行:
显示Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles -bool true
隐藏Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles -bool false
然后重新启动Finder,点击屏幕左上角苹果标志——强制退出——选择Finder然后点击重新启动,这个时候在重新打开Finder就可以看到被隐藏的文件了。
还有一种比较简单的办法就是直接点击Finder图标右键——前往文件夹——输入/Users/your username/Library/Application Support/iPhone Simulator/ ,然后确认就可以了。your username是你本机的用户名
获取文件、library、temp 路径的代码如下:
#import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; NSString *homePath = NSHomeDirectory(); NSLog(@"Home 目录:%@",homePath); NSArray *docPath = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES); NSString *documentsPath = [docPath objectAtIndex:0]; NSLog(@"Documents 目录%@",documentsPath); NSArray *cacPath = NSSearchPathForDirectoriesInDomains(NSCachesDirectory , NSUserDomainMask, YES); NSString *cachePath = [cacPath objectAtIndex:0]; NSLog(@"%@",cachePath); NSArray *libsPath = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES); NSString *libraryPath = [libsPath objectAtIndex:0]; NSLog(@"%@",libraryPath); NSString *tempPath = NSTemporaryDirectory(); NSLog(@"%@",tempPath); // Do any additional setup after loading the view, typically from a nib.}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}@end
0 0
- iOS中的沙盒机制
- iOS中的沙盒机制
- iOS中的沙盒机制
- IOS中的沙盒机制
- iOS中的沙盒机制
- iOS中的沙盒机制
- iOS中的沙盒机制(SandBox)
- IOS开发中的沙盒机制
- IOS中的SandBox(沙盒机制)
- IOS中的沙盒机制(SandBox)
- iOS沙盒机制
- IOS:沙盒机制
- iOS沙盒机制
- ios沙盒机制
- iOS沙盒机制
- IOS 沙盒机制
- iOS沙盒机制
- iOS沙盒机制
- 【leetcode每日一题】148.sort List
- Bootstrap学习:进度条
- IOS--文件管理NSFileManager
- python string包——简易函数使用
- Bootstrap学习:多媒体对象
- iOS中的沙盒机制
- 怎么去掉discuz!的portal.php后缀
- 深入浅出学Spring Data JPA
- Gartner预测2015年十大战略技术趋势
- 写在blog开始的第一天
- Linux C 对日高级软件工程师
- nginx+ajax跨域访问设置
- iOS设计模式——Category
- Bootstrap学习:列表组