Search code examples
iosobjective-cuiimagensdatansurlsession

Is there a performance loss to receiving NSData and transforming it into a UIImage versus getting a UIImage directly?


When I download an image I usually use dataWithContentsOfURL: asynchronously, but it always returns a UIImage.

Is all data that comes over the network initially a form of NSData? Or does downloading it as NSData and then converting it to a UIImage serve as a waste, when I should be trying to download it as a UIImage directly?


Solution

  • Essentially, They They DO The Same Thing(Either way You get NSData), So there is NO performance loss. If you want to improve performance, try SDWebImage (see: https://github.com/rs/SDWebImage). This library caches images and downloads them asynchronously.