Storing images in Core Data or as file?

Abhinav picture Abhinav · Nov 11, 2010 · Viewed 18.5k times · Source

I have set of data which contains images also. I want to cache this data. Should i store them on file system or on core data and why?

Answer

Dave DeLong picture Dave DeLong · Nov 11, 2010

There are two main options:

  1. Store the file on disk, and then store the path to the image in core data
  2. Store the binary data of the image in core data

I personally prefer the 1st option, since it allows me to choose when I want to load the actual image in memory. It also means that I don't have to remember what format the raw data is in; I can just use the path to alloc/init a new UIImage object.