문제

SDWebImage claims that AFNetworking doesn't cache the image itself but just the HTTP response, so SDWebImage is faster in recalling the image from cache and presenting it.

If I wanted to use purely AFNetworking, is such a claim, true or not, really something that is noticeable performance-wise? Is it something I should be wary of?

도움이 되었습니까?

해결책

SDWebImage has much more control over image caching. It can cache to disk or memory.

AFNetworking relies on NSURLCache to persist images between app launches (and it's not very reliable), but it's great if you just need to cache during one run.

Both solutions cache a UIImage object in memory during the lifetime of the app. This is important because caching the NSData representation isn't fast enough to load images smoothly when scrolling through a table view.

Summary: AFNetworking's solution is simpler and will work for most use cases. If you need finer control, or disk caching, use SDWebImage instead of modifying AFNetworking's implementation.

다른 팁

It's not true.

If you look at the code, you can see that the category UIImageView+AFNetworking cache the UIImage (using NSCache and the urlRequest as the key). The cache isn't written to disk though.

I have used both :

SDWebImage is much much faster then UIImage + AFNetworking .

In UITableViewCell you can see the significant difference in performance . It was taking a hell lot of time in AFNetworking and the code is also too long . SDWebImage is much faster and short .

Use SDWebImage for better Image performance .

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top