What is the difference b/w imageNamed and imageWithContentsOfFile in ObjectiveC
imageNamed: imageNamed cache’s your images and you lose control over the memory - there's no guarantee that releasing the object will actually release the image but does provide faster loading of images second time around as they are cached. If you are using Interface Builder, and setting the image in Image View Attributes, that is also equal to imageNamed method. The image will be cached immediately when the app is ran
imageWithContentsOfFile : imageWithContentsOfFile does not cache images and is more memory friendly however as it does not cache images and they are loaded much slower. imageWithContentsOfFile: requires you to put the full path. I don't see why imageNamed: wouldn't be recommended, besides the fact that you can't access files outside of the application bundle.
Got a nice link which explains the difference b/w these two methods image named-vs-image with contents of file
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