What better way to store images in an iOS app?

0

I'm working on an app, and I've read through various websites and articles on how to store image in Core Data or in the app directory.  But I wondered what would be the best way.

I wonder, what would be the best design for this case. To better understand what I plan, the app will receive a product description and an image to represent this product. As the app will have multiple products my concern is to try to keep everything as organized as possible.

    
asked by anonymous 12.01.2015 / 02:34

1 answer

1

The two main options, as you said (and mentioning in this OS question ), are:

  • Save the file to disk and save the path to the image in Core Data.
  • Save the binary image file in Core Data.
  • I need to say that I agree with Dave DeLong and I think the # 1 it is best to allow lazy loading of the image.

    An example of interesting use is to save the URL to the image in Core Data and the first time this image is requested it is locally cached and this URL is replaced by the path of the image.

    Another solution I've seen implemented when there is a business rule of how long the image should remain cached is to save the URL to it and include a lastUsed field, it is downloaded and saved locally and after that pre- should be downloaded again. This solution minimizes the space used and at the same time keeps the most used images available.

    If you choose # 2 at a Core Data Programming Guide and the question Core Data iPad / iPhone BLOBS vs. File system for 20k PDFs .

        
    12.01.2015 / 11:17