查看iOS沙盒(SanBox)文件

每一个iOS程序都一个自己的文件系统,这个文件系统叫应用程序沙盒(SanBox),它存放这代码以外的文件,其他的应用程序不能访问到该程序的沙盒,


如何在本地查看应用程序沙盒?

正常情况下,Finder文件下有一部分文件被隐藏起来,防止被用户破坏,在终端里面用命令打开

显示Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles -booltrue

隐藏Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles -boolfalse

在终端输入以上命令后,回车,然后重启Finder


重启Finder步骤:

查看iOS沙盒(SanBox)文件  查看iOS沙盒(SanBox)文件

然后打开Mac上硬盘文件,找到用户目录,比如我的

颜色浅一点的,矩形画框圈起来(仅仅标记部分)的都是系统隐藏的文件,打开用户

查看iOS沙盒(SanBox)文件


打开用户目录  我的是rjxy

查看iOS沙盒(SanBox)文件


打开rjxy下面“资源库”,这个文件在正常也是被隐藏起来的

查看iOS沙盒(SanBox)文件


找到Application Support文件


查看iOS沙盒(SanBox)文件

对比一下我们创建工程文件夹和模拟器中沙盒下面文件夹

工程目录下

查看iOS沙盒(SanBox)文件


沙盒中

查看iOS沙盒(SanBox)文件


此处输出database.sqlite3的路径

 databse--->/Users/rjxy/Library/Application Support/iPhone Simulator/5.1/Applications/07001BF1-D6C5-4B8C-8E8A-D7B1E4D130EA/Documents/database.sqlite3


以下是寻找database.sqlite3方法

#define kDatabaseName @"database.sqlite3"

databaseFilePath是NSString对象

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);     NSString *documentDirectory = [paths objectAtIndex:0];     self.databaseFilePath = [documentDirectory stringByAppendingPathComponent:kDatabaseName];          NSLog(@"databse--->%@",databaseFilePath);