查看iOS沙盒(SanBox)文件

转载:http://www.2cto.com/kf/201211/169212.html

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

如何在本地查看应用程序沙盒?
正常情况下,Finder文件下有一部分文件被隐藏起来,防止被用户破坏,在终端里面用命令打开
显示Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles -bool true
隐藏Mac隐藏文件的命令:defaults write com.apple.finder AppleShowAllFiles -bool false
在终端输入以上命令后,回车,然后重启Finder

重启Finder步骤:

然后打开Mac上硬盘文件,找到用户目录,比如我的颜色浅一点的都是系统隐藏的文件,打开用户

通过下面的代码获得文件路径,根据路径找到沙盒中的文件:

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = paths[0];
NSString *writableDBPath = [documentDirectory stringByAppendingPathComponent:DBNAME];

NSLog(@"%@",writableDBPath);

打印路径如下:

/Users/bettem/Library/Application Support/iPhone Simulator/7.0.3/Applications/2BDEF2DB-6726-47AA-9D72-D63D7093F1CC/Documents/Thesaurus.sqlite

根据路径,找到沙盒中文件Thesaurus.sqlite

 

posted @ 2013-11-04 15:58  zhangze  阅读(660)  评论(0编辑  收藏  举报