If I assign an image to a UIImage view in a xib, is that image cached so that if I access the image using UIImage imageNamed: I am getting cached Image data?
I’m using iOS 5.1
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
UIImage imageNamed:does its own cacheing of any images you use. The first time you use it for a given image, it’ll populate the cache, and subsequently it’ll use the cached version.UIImageViewin Interface Builder takes a string to tell it what image to use. It appears that the object that is actually encoded in the Xib to represent the image is a private class calledUIImageNibPlaceholder, which contains a private NSString variable calledruntimeResourceName. It’s this class that implements theinitWithCoder:method which is used when the system is loading objects from a xib.So, the question is, inside
UIImageNibPlaceholder‘sinitWithCoder:, does it use theimageNamed:function ofUIImage? I think it’s reasonable to assume that it does, since the thing stored in the xib is the stringruntimeResourceName, and the system is turning that string into an actual image when loading the xib.This post on the Apple developer forums seems to clarify the point (under NDA so I can’t copy it here). I couldn’t find any publicly accessible information on the subject.