I am planning to use Core Data in my app If there is no internet connection.
So what i am doing is retrieving images and videos from my server. I currently download them (Images for example) from the url retrieved from the server and convert it to UIImage NSData and then populate my tableView.
Now to the CoreData:
Some may say storing files in coreData is a bad idea, But as I shall only store a maxium of 5 images/videos at once I don't thing storage or speed shall be a problem as they will not be enourmous files.
To the question:
I have to save I guess the UIImage to CoreData, so obviously I need to get the URL then download the image and finally save it to coreData.
But If I do so in my query for getting the actual posts that would slow down the query possibly a couple of seconds, and I would prefer not to do so. So I was wondering what would be the best way?
I am downloading the images async with SDWebImage each time a cell appears, so If I save the images to coreData once they are downloaded that would mean to save 5 images to CoreData I would need to scroll 5 Cell's.
But I would prefer to: Load the app, download the Images/videos from server as normal and populate the tableView, and once all that has happened I would like the post's to already be saved to coreData.
So If I immediately close the app after the tableView gets populated then disconnect from the internet or go into AirPlane mode and re-open the app I have the posts in the tableView.
I know how to do most of the saving to coreData etc... But I would like some more proffessional advice and tips on how I should approach this.
What I would like to achieve?
1) Open the app
2) Download 5 images/video from the server (Up too here all good)
(From here on I would like some advice)
3) Empty the coreData if there was any previously images/videos saved
4) Save the last 5 images/videos I downloaded to CoreData.
What would be the best solution and quickest way to do so?
Thanks to anyone that can offer some advice.