我将图像文件存储在 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/