ThuongNM
ThuongNM

Reputation: 25

iOS how to cache data when kill application?

I am developing a new feature for my app. I want cache all datas get from web service to read when offline.
Current, my app can cache data but when I killed my app It didn't work.
I saw an application https://itunes.apple.com/us/app/smartnews-trending-news-stories/id579581125?mt=8 can cache everything when killed application.
Do you have some suggest for me?
Thanks.

Upvotes: 0

Views: 999

Answers (2)

Fahim Parkar
Fahim Parkar

Reputation: 31647

The best option is whenever your webservice call is done, save the json data in sqllite and then make all operations over sqllite DB (like displaying that data on UI) & not over data that you received in json...

This is what FB do (& hence when you open the app, you see old posts without any downloads)

For images use SDWebImage library

Upvotes: 2

Reshmi Majumder
Reshmi Majumder

Reputation: 961

You can use coredata as it is faster to access and easy to implement and if images are there then you can use the documents directory to save it and save the path to coredata

Upvotes: 0

Related Questions