Clicky

iOS Dev Nugget 34 When do you use UIImage's +imageWithContentsOfFile: over +imageNamed:?

.

Need to run a code review on your codebase? Hire me

The key difference between +imageWithContentsOfFile: and +imageNamed: is the former always read the specified file from the filesystem for every call whereas the latter checks a system-maintained cache and only reads from the filesystem when it isn't available in the cache. So generally, you'd want to load images used in your UI with +imageNamed: and use +imageWithContentsOfFile: for images that are not repeatedly used within the app to improve the performance and memory footprint of your app.


Your feedback is valuable: Do you want more nuggets like this?   Yes   or   No

.

.

Like this and want such iOS dev nuggets to be emailed to you, weekly?

Sign Me Up! or follow @iosdevnuggets on Twitter

.

View archives of past issues