0

I am developing a simple photo editing app. I would like a journal feature for the user to view each of the photos they've edited. Some power user might have hundreds (or potentially thousands) of photos.

I am using Core Data to save photos. My concern is that hundreds of 640x640 photos might make the documents directory filesize rather large (side question: My assumption is my core data store is saved to my apps Documents directory. Is that true?).

Is it a problem to store so many photos locally within the app or am I being overly cautious? Is there a filesize limit on how much I can store?

Andrew Davis
  • 2,310
  • 1
  • 24
  • 43
  • 2
    Just wondering if performance which it would make sense to store the image itself in document directory and only save the image file path in coredata. – rckoenes Apr 08 '14 at 11:23
  • Generally speaking @rckoenes has the best solution. Use a database (CoreData in this case) for storing data that will be searched. Store large data in files pointed to by the database. – zaph Apr 08 '14 at 11:26
  • Sorry, I should've been more clear. I am actually doing that. Saving the photo in documents directory and then storing the filepath in core data. – Andrew Davis Apr 08 '14 at 11:26
  • @AndrewDavis any update on your question? – Michal Apr 15 '14 at 11:35

2 Answers2

1

There is no limit for storing data in the documents directory (supposing you're using documents for data and core data for paths). There was a discussion on that in this question. Other than that, you'll be fine, working with data from documents directory is rather fast by default.

The thing is - will your users be happy with your app getting bigger and bigger? Can you perhaps give them the option to store the pictures on the server and let them set the cache size?

OR - you could go for storing it in the photo library if you get stuck with it...

Community
  • 1
  • 1
Michal
  • 15,429
  • 10
  • 73
  • 104
  • thank you. Server side storage is not an option. Hundreds/thousands of photos are fringe cases so I'm planning for the extremes. I will likely enforce a cap on total photos that can be stored. – Andrew Davis Apr 15 '14 at 14:06
  • I've just had a thought though, could I create an album in Photos app and populate that with the photos (as opposed to using my apps doc directory). Then my app could pull in these photos (if it's possible to populate a UITableview from a specific photo album)? – Andrew Davis Apr 15 '14 at 14:12
  • 1
    Sure ou can - with `ALAssetsLibrary`. The problem is that the data is in the hands of the user - he/she can delete the whole album/rename it/delete some pictures from that album you create...so the file management would be out of your control... – Michal Apr 15 '14 at 15:20
0

The database location is specified in the method NSPersistentStoreCoordinator:addPersistentStoreWithType:. I think apple generates this to be in your documents directory. So you are correct in assuming its in the Documents dir.

On your main question I'm tending to think it is possible to do what you are saying (theres no limits on core data) but it might lead to not a nice experience for the user as it could lead to your app growing in an uncontrolled way. So syncing might slow up and your app might not be politely behaved for the user. So I don't think its a good idea as it stands if your power users will have 1000s of photos

Perhaps consider introducing a maximum quota of images that the app can deal with and loading/downloading images from an URL which you would specify as a path. What about using the SD card as an back up option. Hmm a lot of work I don't envy you. Mayby someone else has done something similar and they could give you a start.

I consulted the following Previous answers on stack overflow which deal with your issues raised mayby they help you to.

Core Data - Storing Images (iPhone)

Storing photos and videos in Core Data?

App Updates, NSURL, and Documents Directory

CoreData (for iphone) storing images

Storing large (e.g. image/movie) files in Core Data on the iPhone

Size limit of my ios app particularly Core Data

Hope this helps some what.

Community
  • 1
  • 1
Frank Brosnan
  • 231
  • 1
  • 2
  • 8