Reputation:
We get image for JSON url,And then We saved image in NSMutableArray(imageArray). We have four different UIViewControls. Every Page uses this imageArray. We are not interested to call web service every page. We need imageArray Stored to Local JSON file and then we Retrieve Data form JSON.
So Please give me any idea.Thanks in Advanced.
Upvotes: 0
Views: 1099
Reputation: 2405
Best solution to cache server response is to download the images using NSURLRequest/NSURLConnection, and use proper NSURLRequestCachePolicy to cache response.
To sort out your problem you can use NSURLRequestReturnCacheDataElseLoad
cache policy. It will load data from server if there is no cache data locally and if found any local data then returns it without hitting server again.
For more on NSURLRequestCachePolicy and cache server response, you can read here:
http://www.hpique.com/2014/03/how-to-cache-server-responses-in-ios-apps/
http://codewithchris.com/preventing-nsurlconnection-cache-issues/
http://nshipster.com/nsurlcache/
Upvotes: 1