The option to not cache data is NSDataReadingUncached
.
But if I use dataWithContentsOfURL
to update the images from URLs in a UITableViewCell
(one image per cell), and I look at the Activities Monitor on the Mac for the Simulator (running as iOS 5.1 simulator), then the network traffic jumps up to 12kb/s receiving rate when I scroll the table up and down continuously. When I stopped scrolling up and down, the network activities drops down to about 2kb/s receiving rate or lower. Those images are very small, like 20kb or so each, and when I scroll up and down, I only make 1 or 2 image disappear / appear, so the cache, if any, won't need to be large at all.
So it does look like dataWithContentsOfURL
does not cache data, and even when I use dataWithContentsOfURL:options:error:
with options being 0
to mean no option, the network activities still jump up to about 12kb/s.
So does dataWithContentsOfURL
caches data, and if not, why does dataWithContentsOfURL:options:error:
has the option of not cache data?
The following is also done:
[[NSURLCache sharedURLCache] setMemoryCapacity:1024*1024*10];
in viewDidLoad
but the network rate still will jump up. I think the usual recommendation is that if caching is desired, then use NSURLConnection
, but for some reason, in the NSURLConnection
reference on Apple's doc, the word "cache" or "caching" doesn't appear at all except there is mentioning of a sample project called "URLCache", but no mentioning of caching at all.