in iOS 7 cachePolicy doesn't work, it just cache the downloaded json.
//URLRequest
NSString *url = [NSString stringWithFormat:@"http://www.semhora.com/jsonparser/categories/categories_%d_test.json", _categoriesIndex];
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:url]
cachePolicy:NSURLCacheStorageNotAllowed
timeoutInterval:60.0];
How can I disallow cache in iOS 7?
I encountered the same problem and I verified that setting cachePolicy = 0
instead of cachePolicy = NSURLCacheStorageNotAllowed
fixes the problem.
This doesn't make sense to me either since 0 corresponds to NSURLCacheStorageAllowed
.
We can't just set it to 0 since Apple will probably fix this in a future release.
You might try calling:
[NSURLCache sharedURLCache] removeCachedResponseForRequest:yourRequest]
just before initiating the request.
UPDATE: After further research I found that the code that broke has been using the wrong enum. Take a look at NSURLRequestCachePolicy in NSURLRequest.h. That's the one you need and it explains why setting to 0 fixed the problem for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With