iOS物理内存管理(文件缓存)

标签 ios memory-management swift

我将图像文件存储在 Documents 目录中以进行文件缓存。

var paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as String
var path = paths.stringByAppendingPathComponent(imagePath!)
data.writeToFile(path, atomically: true)

存储这么多文件会发生什么?有自动交换功能吗?或者我可以用代码检测它吗?

注意:我不想使用 tmp 目录。

最佳答案

这就是我想要的。谢谢@gnasher729。

Put data cache files in the Library/Caches/ directory. Cache data can be used for any data that needs to persist longer than temporary data, but not as long as a support file. Generally speaking, the application does not require cache data to operate properly, but it can use cache data to improve performance. Examples of cache data include (but are not limited to) database cache files and transient, downloadable content. Note that the system may delete the Caches/ directory to free up disk space, so your app must be able to re-create or download these files as needed.

关于iOS物理内存管理(文件缓存),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26561807/

相关文章:

ios - 使用 Alamofire 的授权 header

ios - 混合 ARM 和 THUMB 指令

java - 为什么我的程序越来越慢?

javascript - 缓存 HTML 字符串或 DOM 元素?

swift - NSUserDefaults 已经有键值对了吗? - swift

ios - 使用Swift进行 Realm 保存的问题。我错了,我直接从Realm Browser 0说了“删除对象”

iOS swift prepareForSegue 无法在两个 View Controller 之间传递数据

ios - 如何在核心数据中保存图像的引用(图像 URL 或路径)并在需要时加载?

ios - 有没有办法在不刷新单元格的情况下显示单元格中的对象?

c++ - 如何确定 C++ 应用程序中的可用 RAM 量?