|
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 Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.
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.