ios - Do we need to cleanup downloaded image files? -
in ios app downloading bunch of image files , saving them on disk in library/caches. need delete files given ios automatically clears them when running low on disk space.
it depends save them. read file system programming guide detailed discussion.
in summary, if saving files to:
- temp: don't need worry cleanup, need aware these files not persist between app launches
- library/caches ios won't delete these files can clear them when running on low disk space. developer has make sure these files can regenerated when required.
- all other folders yes, need make sure files cleaned when no longer needed.
update: have specified saving library/caches, from apple docs caches directory:
use directory write app-specific support files app can re-create easily. app responsible managing contents of directory , adding , deleting files needed.
in ios 2.2 , later, contents of directory not backed itunes. in addition, itunes removes files in directory during full restoration of device.
on ios 5.0 , later, system may delete caches directory on rare occasions when system low on disk space. never occur while app running. however, should aware itunes restore not condition under caches directory can erased.
to specific your app responsible ... adding , deleting files needed., should always clean after yourself. if know done files, keeping them on disk , waiting device run on low disk space os deletes them bad idea.
btw, if downloading files internet, why don't use build library (so don't have worry these things).
- if developing ios 8.0+ , using swift, use alamofireimage embedded framework. comes caching system. think can use on ios 7 copying swift files.
- if using objective c, use sdwebimage comes own caching system. use afnetworking , enable basic caching, this blog post should started.
Comments
Post a Comment