|
Good afternoon. I am doing a test. "Offline mode: i.e. if there is no network access, show the last downloaded data" I can't figure out how to save data. The model contains both text and links to the image. Please tell me how this is implemented. I think through the UserDefaults 🙄 |
|
|
|
|
|
Consider that an application's UserDefaults is stored with your application. By design, it probably should store small chunks of data and preferences. Preferred color scheme. Last date of log in. User profile. This sort of data. The iPhone has a document directory that's designed for storing much larger files. Pages documents. Cat memes jpegs. Web links that you never seem to revisit. Selfies. Hundreds of large files. I think @Gakkie is pointing out if you have a LARGE file of json data as an offline version of your application's data set, consider storing that json file in your document's directory, rather than in UserDefaults. |
|
Some thing like below , using a json and storing it in DocumentsDirectory and retrieving it
|
|
I have this
Then you want to check if you have internet access
You might want URL extension too
|
|
SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!
Sponsor Hacking with Swift and reach the world's largest Swift community!
You need to create an account or log in to reply.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.