'How to load data from local storage if Network request fails Swift
I'm loading products for my app from Network every time the user opens an app.
My viewDidLoad looks like this:
override func viewDidLoad() {
super.viewDidLoad()
viewModel.loadProducts()
}
loadProducts func loads an Array of products
let products: [Product]
I want my app to save the previous array so in case of loadProducts() fails I will initialize products from phone local storage.
What are my steps to achieve that? and is it hard to do?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
