Abhinav Abhinav - 1 year ago 60
iOS Question

Storing images in Core Data or as file?

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 Source

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.