tags:

views:

31

answers:

1

I'm able to pull information from a plist using:

nameTextField.text = [recipe objectForKey:NAME_KEY];
ingredientsText.text = [ingredients objectForKey:NAME_KEY];

I also have images in the plist [the names of the images, not the image data]

does anyone know how i would display an image in a similar manner?

thanks in advance.

A: 

You'll have to create an image with the contents of the file at the stored path. Either use imageWithContentsOfFile: or imageNamed:, where imageNamed: takes only the filename and caches images, useful for images that are small and appear often in the UI. Also note, that imageNamed: searches for a @2x-Version of the image in iOS4.

imageWithContentsOfFile takes a full path including your app-bundle's path and dose not have a cache. It's intended for larger images that only appear once on a screen.

imageView.image = [UIImage imageNamed:[recipe objectForKey:IMAGE_KEY]];
imageView.image = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] 
                           pathForResource:[recipe objectForKey:IMAGE_KEY] ofType:nil]];
tonklon
that worked great. thanks for the help
hanumanDev
Then please mark it as the accepted answer.
tonklon