vongolashu
vongolashu

Reputation: 375

Offline Blog Reading (Images) capability (cache)?

I am creating a UITableView where I will load and show data from my blog's feed. This data will be updated daily, on launch or dynamically.

What I want to do is provide some offline capability to this screen, as such if user isnt connected to internet, he can still see the view and its contents (mainly post list with its images).
For such I will need some hints or solutions on how to do this, probably cache ?

Basically if user is connected to net, the view will update the contents and fetch he blog post feeds from my API and update it with new content, but if user isnt connected to net, he should see the last fetched/updated content (with images) till he connects to net and updates the view.

For this probably I need to save/cache 3 things which I will need and use in the View, all of which are fetched and provided by my API:- The Post Title, Date and its cover image.

Would best way would be to add them to some dictionary, use NSCache (aint it temporary ?) or download images locally and then save them as UIImage along with NSString (title/date) in a dic/array ?

I would like to know as many different approaches possible.


After testing a bit, I found caching images can solve my offline image problem, but is cache temporary or how long can it last ? How can I store that cached image with my text data in some dictionary to load it if network isnt connected ?

Upvotes: 0

Views: 69

Answers (1)

Nikos M.
Nikos M.

Reputation: 13783

You can use a ready to use, opensource caching library like SDWebImage. It provides asynchronous image downloading as well as caching, so any image that is cached will appear in place when your app is offline.

Upvotes: 1

Related Questions