Reputation: 3875
I am trying to figure out if dataWithContentsOfURL
caches the contents, so that if in the code:
UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:
[NSURL URLWithString:[NSString stringWithFormat:@"http://testsite.com/img/%@.png"
,imgName]]]];
a line would follow:
UIImage *img2 = [UIImage imageWithData:[NSData dataWithContentsOfURL:
[NSURL URLWithString:[NSString stringWithFormat:@"http://testsite.com/img/%@.png"
,imgName]]]];
Would that require going to the network again?
Upvotes: 0
Views: 821
Reputation: 3774
This is not cached.
I recommend you start using ASIHTTPRequest or AFNetwork frameworks. They allow you to cache.
You have some ways to do caching if you do NSMutableURLRequest, but not great ones.
You should also not use XWithContentOfURL as they tie up your main thread, unless you use threads or GCD, things you get for free if you use the above frameworks
Upvotes: 1