天天看点

iOS应用目录结构和操作

iOS应用目录结构和操作

paste_image.png

/var/mobile/applications/4dcf7000-bd28-4494-80df-4f081c975edc

phone会为每一个应用程序生成一个私有目录,ios7这个目录位于:/var/mobile/applications,随机生成一个数字字母串作为目录名,每一次应用程序启动时,这个字母数字串都是不同的。

documents:保存应用运行时生成的需要持久化的数据,itunes会自动备份该目录

"/var/mobile/applications/4dcf7000-bd28-4494-80df-4f081c975edc/documents"

~/documents

libaray/caches:存放缓存文件,itunes不会备份此目录,此目录下文件不会在应用退出删除,一般存放体积比较大,不是很重要的资源

打印:

/var/mobile/applications/4dcf7000-bd28-4494-80df-4f081c975edc/library/caches

打印: ~/library/caches

libaray:存储程序的默认设置和其他状态信息,itunes会自动备份该目录

打印:"/var/mobile/applications/4dcf7000-bd28-4494-80df-4f081c975edc/library"

打印:~/library

libaray/preferences:保存应用的所有偏好设置,ios的settings(设置)应用会在该目录中查找应用的设置信息,itunes会自动备份该目录。

/var/mobile/applications/4dcf7000-bd28-4494-80df-4f081c975edc/library/preferences

tmp:保存应用运行时所需的临时数据,使用完毕后再将相应的文件从该目录删除,应用没有运行时,系统也可能会自动清理该目录下的文件,itunes不会同步该目录,iphone重启时该目录下的文件会丢失

/private/var/mobile/applications/4dcf7000-bd28-4494-80df-4f081c975edc/tmp/

<code>nsfilemanager</code> 是处理文件系统的 foundation 框架的高级api。它抽象了 unix 和 finder 的内部构成,和 icloud ubiquitous containers 一样, 提供了创建,读取,移动,拷贝以及删除本地或者网络驱动器上的文件或者目录的方法。

<a href="https://developer.apple.com/library/ios/documentation/filemanagement/conceptual/filesystemprogrammingguide/filesystemoverview/filesystemoverview.html#//apple_ref/doc/uid/tp40010672-ch2-sw2" target="_blank">https://developer.apple.com/library/ios/documentation/filemanagement/conceptual/filesystemprogrammingguide/filesystemoverview/filesystemoverview.html#//apple_ref/doc/uid/tp40010672-ch2-sw2</a>

<a href="http://nshipster.cn/nsfilemanager/" target="_blank">nsfilemanager http://nshipster.cn/nsfilemanager/</a>

<a href="https://developer.apple.com/library/ios/documentation/filemanagement/conceptual/filesystemprogrammingguide/managingfilesanddirectories/managingfilesanddirectories.html#//apple_ref/doc/uid/tp40010672-ch6-sw2" target="_blank">官方文档</a>