Reputation: 746
I have a bunch of images that I want to save to my app but I'm worried about taking up too much space on the device.
Is there a way to check how much space I'm taking up? And how do I know when I am taking up too much space and I have to delete some things?
Thanks
Upvotes: 3
Views: 734
Reputation: 746
I actually ended up using EGOImageLoading from Enormego.
It apparently downloads the images asynchronously, allows you to use a placeholder while waiting for the image to download, and caches the images so they're accesible offline.
Upvotes: 1
Reputation: 47241
Have a look at Calculate the size of a folder…, you'll find some ways to calculate the size of a folder. As far as I know there is no size limit to how much data you can save on the device. However if the device's disc is full saving data will fail.
Look at http://kdbdallas.com/2008/12/27/maciphone-show-availble-useable-diskspace/ on how to find out how much disk space is available.
You can also make use of NSFileManager's instance method attributesOfFileSystemForPath:error:. It returns a dictionary, have a look at the keys, especially NSFileSystemFreeSize.
If you run out of space you should delete files of course, at least present the user some information on how much space the app is using up.
Upvotes: 3