Answer the question
In order to leave comments, you need to log in
How to save Image in UserDefaults?
I get an image from the network by url, then I display it as a UIImage.
I wanted to make sure that when the Internet was turned off, the previously downloaded pictures were saved and questions arose.
1) Do I need to convert the image to jpeg? For some reason, in the guides I saw only this way.
2) Where should we populate and retrieve data to/from UserDefaults? (I'm using tableView) In a function that configures a UIImage to display in a cell? or a tableView delegate method like didSelectRowAt?
ps Maybe these are stupid questions, but this is the first time I've encountered UserDefaults.
Answer the question
In order to leave comments, you need to log in
The image definitely does not need to be saved to UserDefaults
AND the image does not need to be saved to the database
Only to a file
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question