Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
因此,当磁盘空间不足时,操作系统基本上会删除应用程序缓存目录中的所有磁盘内存,有没有办法确定当前有多少磁盘空间用于缓存数据?
不。
通常,您永远无法访问文件系统。因此不是其他应用程序使用的缓存。
如果您将问题重新问为“有没有办法知道我的应用程序在缓存中使用了多少磁盘空间,答案是肯定的。
遍历缓存目录的文件系统,使用NSFileManager和使用[NSFileManager attributesOfItemAtPath:error:]来获取每个文件的大小。
NSFileManager
[NSFileManager attributesOfItemAtPath:error:]