I’m sending an image name from a view controller. In the recieving view controller I want to set the image in UIImageview to the string plus .png
The code I’m trying (which doesn’t work) is:
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *imagefile;
imagefile=[NSString stringWithFormat:@"%d.png",myColour];
myImage.image=[UIImage imageNamed:imagefile];
[output setText:myString];
// [imagefile release];
}
In the code here myColour is the string passed from the previous page – so I have images called yellow.png, blue.png etc
Thanks.
The code you want is:
Use %@ to print values from objects (NSObject subclasses, like NSString).