Xcode 4 UIImage imageNamed: Method Not Found Error

While working with an Iphone Application i wanted to display an image using UIImageView control i have designed using Interface Builder. The working environment is Mac 10.6, Xcode 4 and IOs SDK 4. Required images added to Resources folder in project. The code line is as below.

[imageView1 setImage:[UIImage imageNamed:@”130_001.jpg”]];

When i build and run application compiler break at this point and throw an error : Method ‘+imageNamed:’ not found (return type defaults to ‘id’)

I tried searching everywhere including IOS SDK documentation but could not find anything related to this issue. Finally, i tried to assign image to UIImageView in two steps. First is creating UIImage object using imageNamed method and then assign that image object to ImageView using setImage method. imageView object already added to Interface Builder. I did this in two steps below:

UIImage *image = [UIImage imageNamed: @”130_001.jpg”];
[imageView1 setImage:image];

As you see there is not much difference in both code. Somehow image object could not assigned directly using setImage method. If you have any idea please share your information using comments box.

Written by Bala Krishna

Bala Krishna is web developer and occasional blogger from Bhopal, MP, India. He like to share idea, issue he face while working with the code.

Leave a Comment

Your email address will not be published. Required fields are marked *