how many images can I cache in my iPhone app? - iphone

I'm wondering how many images I can store in the iPhone documents directory so that I don't get any memory issues. I'm torn between caching images or loading them from a webserver every time the user wants to access them. There most likely won't be more than 10-20 images cached at any given time...
Any thoughts?

There's a 2GB cap on the largest size of a single file in the /Documents folder. Other than that, you can store as many images as you want. iOS itself didn't put a limitation on how much space you can use on a device. So your space limit is the size of Flash on the device (i.e. 16GB, 32GB etc).
You might consider use the /Library/Caches instead because iCloud will attempt to sync the Documents folder (if entitlements are configured). I heard App being rejected by review for excessive use of the Documents folder. To get the path, call NSSearchPathForDirectoriesInDomains with NSCachesDirectory and NSUserDomainMask.
Though a user can determine the size of space you are occupying in System Settings.

You can probably cache as many files as available memory allows, but you absolutely should be safe having 10 - 20 images cached at any given time.
B.T.W., instead of using the documents directory, why not consider using the cache directory as He (+1 to him!) suggests?
Here is a related question that shows how to get the size of the directory.

Related

App Size Limit and Finding the size of your app

Okay, so i've read countless places saying the app size limit is either 20 mb and some say it's 50mb... which is it?
More importantly, my current app has an "estimate app store size" of 106.1mb in the Archive section of the Organizer. HOWEVER, when I distribute it to an ad-hoc file, it comes out as a .ipa which has the size of 48.3mb. Which one should I use, and I'm confused as to why they are so different.
The official (and reliably up to date) resource for this is the Uploading Your Binary section of the iTunes Connect Guide (expand the 'To begin the Ready to Upload Binary flow' section). At the time of this edit it states:
iOS App binary files can be as large as 2 GB, but the executable file (app_name.app/app_name) cannot exceed 60 MB. However, consider download times when determining your app’s size. Minimize the file’s size as much as possible, keeping in mind that there is a 100 MB limit for over-the-air downloads.
Over-the-air download limit means apps below this threshold can be downloaded with a mobile data connection (anything above the limit requires a WiFi connection, or to be downloaded through iTunes on the computer). This is important as many users may not have ready access to WiFi and you don't want to prevent them from being able to get your app!
Also the .ipa is a compressed, encrypted zip file, whereas the archive is just a fully inflated package of the app, which is why the file sizes are different. The .ipa file size is the one that will be used in the App Store, so use that as your reference for total size. That said, the smaller you can make your app, obviously the happier the user will be!
Apple recently bumped up the size from 20 to 50 shortly after WWDC '12. I am not sure if it was officially announced, but was observed in the error message of larger apps.
Use the IPA size. The files sent from the app store are compressed. Perhaps the 106.1 is the uncompressed size, or it is a bug.
Today, Apple Increases Over-the-Air App Store Download Limit to 100MB.

how can i do Limit the file app size in ipad?

I want to write a app to download and manage files from the web. If I just put the file in the Document. Is there any limit of file size in the Directory?
can any one help me..
thanks in advance.
Just a warning with the introduction of iOS5 saving large files or files that can be regenerated into the documents directory is frowned upon (actually you were never meant to do it but its only being enforced now). This is because the files in the documents directory get backed up to iCloud and you obviously do not want to fill that up. Apple have started rejecting apps just for this reason.
You should now place the downloaded files into the temp or cache directories. But also be aware that the OS will clear these directories when running low on memory so you need to have logic in you app to check if the files exist and re-download if they do not.
No real limit except the device and other user data. Still best to be frugal.

What are the storage limits for iPod/iPad applications?

I'm not talking about binary size. I'm talking about the amount of data that can be written to disk during execution inside of certain directories such as Cache or Documents.
I can't find an easy answer in the XCode documentation, which is to say I can find none at all.
I know there is a limit for the cache directory in the form of "oh hey, your device is crashing now", but I haven't determined the actual number, and I am not sure if the Documents folders or other folders have the same restrictions.
Links and numbers are appreciated!
There is no reference or limitation of disk space once the application has been installed to the iPhone, iPad, or iPod Touch device.
The only limitation would be available disk space (whole disk space available) at time of writing to those directories.

Does the iPhone / iPod touch cache data also on disk, or only in memory?

I am not sure, but I think I was reading a while ago that iPhone / iPod Touch don't cache anything to disk. They cache only in memory. So cache is not persistet when app quits. After relaunch of app it will re-fetch the data from the net. Is that true?
iPhone OS disables on-disk caching from NSURLCache on this platform. If you need on-disk caching support anyway, you can use http://github.com/rs/SDURLCache which gives back on-disk cache support on iPhone OS
You can explore this yourself using the iPhone Simulator, opening a terminal or using the Finder, and going to `~Library/Application Support/iPhone Simulator/User/Applications/ then opening whatever directory your application is in.
You'll see a Documents directory, a Library and a tmp directory.
I've never looked to see if UIWebView is caching anything, but I know that Core Data will.
If you just suck down data yourself using CFNetwork, I believe it's up to you to cache the data yourself by saving it to tmp or Documents if you want.
tmp will not get backed up by the iTunes Sync process, but Documents will, so don't use Documents for temporary cache. Otherwise you'll just waste space and slow down sync backups.
The Documents directory will persist through anything, including app upgrades, except outright deleting the application using the Springboard or doing a total device storage wipe.
Actually the Library directory has directories. called Cache, WebKit/LocalStorage, and Preferences. So that would suggest something or the other.
Don't write to the application bundle directory or bad things could happen.
iPhone apps can write data to disk.

iPhone programming: How much data can I store in my app's Documents Directory (root folder)?

The reason I ask is my app lets users cache map tiles. Does anyone know the real cap on how much data I can let them store?
You can store as much as you want until you run out flash. Having said that, your users probably won't like it if you start eating all of the space on the phone.
Also, make sure you put it in the Cache folder, as opposed to Documents. The Documents folder gets backed up when you sync to iTunes, the Cache folder is not. If you have a ton of data in the Documents folder it will massively slow down iTunes synching.
About a year ago the word was there is a 2Gb limit on app size, but you'll be hard pressed to find an "official" declaration of such, even on apple's site or the discussion forums there
That being said 2Gb is pretty hearty for a mobile app, caching and all
I'm not aware of any quota for apps using the writable area, but it would be easy enough to check.