简体   繁体   中英

how many images can I cache in my iPhone app?

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?

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.

BTW, 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 .

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 (ie 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM