Search code examples
iosjsonswiftapialamofire

how to store JSON response into cache while using Alamofire in Swift


Can anyone tell me the best approach to use cache while getting response from api. I'am using Alamofire '4.7.3' and swift 4.2


Solution

  • If you have a JSON response, convert it into a string and save it locally. Parse back the objects using the Codable protocol. Anyway the best approach would be to parse it into objects and then save the objects into CoreData (or Realm...)