Search code examples
iosobjective-ccore-dataafnetworking-2

Load multiple images to core data using afnetworking


I have created request to url where is json and I stored all data from json to NSArray. There are links to images which I want to retrieve from it and save it into core data. For this process I'm using afnetworking which properly cache all data from json without any problem but I don't have resolution how to store it to core data model.


Solution

  • You should not store images in Core Data, unless they are tiny, such as thumbnails. Instead, use one of two options:

    Check "External Storage" in the model editor. Core Data will then store the images outside the database, making it much more efficient without degrading performance.

    Alternatively, you could devise your own system with NSFileManager and use the application documents directory to keep track of the pictures.

    Your Core Data Image entity should contain the original URL and either the externally stored image as data type BLOB / NSData or a reference to the local file (by file URL or some naming convention).