last day (14 days later) » 

13:43
1
A: How to cache NSUrlSession reponse data

vaibhavYou can handle cache data using NSMutableURLRequest class setCachePolicy method. There are many methods works accordingly have a look. NSURLRequestReloadIgnoringCacheData: This methods ignores cache data and fetch the fresh updated response from server. Specifies that the data for the URL load...

I added this policy request.cachePolicy = NSURLRequestReturnCacheDataElseLoad; but I am not able to cache data.Can you please tell me how to check data is coming from cache or not.
if you dont use and cachePolicy method by default you are loading data from cache.
I also tried with request.cachePolicy = NSURLRequestReturnCacheDataDontLoad;but nothing data showing,means cache not working
No, there is age of data expiration over cache when you use this method it returned data if exists but no attempt is made to load the data from the originating source(means your server).
@Yatendra you can accept and upvote ans if found useful.
can we load data in offline mode.I found this "NSURLRequestReturnCacheDataDontLoad".but it's not working.
13:43
yes, but before that you can search for the data expiration age.
I have seted timeoutInterval:60.0 but in offline it's not working
this doesn't sets the age of data existence, it sets the receiver’s timeout interval. look.
I tried cahed control
- (void)URLSession:(NSURLSession *)session
dataTask:(NSURLSessionDataTask *)dataTask
willCacheResponse:(NSCachedURLResponse *)proposedResponse
completionHandler:(void (^)(NSCachedURLResponse *cachedResponse))completionHandler
{
NSURLResponse *response = proposedResponse.response;
NSHTTPURLResponse *HTTPResponse = (NSHTTPURLResponse*)response;
NSDictionary *headers = HTTPResponse.allHeaderFields;

NSCachedURLResponse *cachedResponse;
if (headers[@"Cache-Control"])
{
NSMutableDictionary *modifiedHeaders = headers.mutableCopy;
but it's not works in offline
why you trying to access cache when offline ..?
all these are not so reliable when offline mode
beacuse i need to get some data in also offline
13:49
just check the internet connectivity and load the data from local db ..
simply create local db ..and load from there
I think w/o local db it's possible
yes
you can insert data in local db and loads when user is offline ..
cache is just to improve the time taken by a single request ..
so it doesnt gets data from original source and take too much time ..everytime
using cache to load data when user offline ..never never never
doesnt make a sense to be a good developer ..
just think first draw second and develop last ..
but
NSURLRequestReturnCacheDataDontLoad
check this one
okay you say what inside this ..
dont have time to read this
No,
i am saying that here for NSURLRequestReturnCacheDataDontLoad
is wrriten offline mode
14:05
just read this carefully
it also saying what i have told to you ..
and please upvote and accept ans for my valued time .. :)
if you got anything from me ..

last day (14 days later) »