0

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.

ThuongNM
  • 25
  • 6

2 Answers2

2

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

Fahim Parkar
  • 30,974
  • 45
  • 160
  • 276
  • how about NSCachedURLResponse? I used AFNetworking in my project. Do you have some solution for caching AFNetworking. – ThuongNM Jan 26 '16 at 07:42
  • @ThuongNM : I think NSCachedURLResponse will get expired after some time... I never used AFNetWorking – Fahim Parkar Jan 26 '16 at 07:55
  • AFNetWorking return an id response, how to save it? and how about core data? – ThuongNM Jan 26 '16 at 08:24
  • @ThuongNM : instead of coredata go with sql lite.. its very easy to understand... check [this link](http://www.appcoda.com/sqlite-database-ios-app-tutorial/) – Fahim Parkar Jan 26 '16 at 09:06
0

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

Reshmi Majumder
  • 961
  • 4
  • 15