Sunderwood
Sunderwood

Reputation: 11

UIImage setting value from filename in database

I have a SQLite database containing several items of data and in there i have included a column with the file names of the images i want to use in my app.
I know how to pull this data out but i dont know the correct syntax to use to set that filename to the uiimage.
Here is an example of what i thought it would look like.

UIImage *animalImage = [[UIImage imageNamed:[database imagefilename];  
self.childController.stepImage.image = animalImage;

Upvotes: 1

Views: 381

Answers (1)

RichB
RichB

Reputation: 118

Assuming '[database imagefilename]' returns an NSString with the filename of the image then this looks good. You're missing a ']' at the end of the first line (but I assume thats a copy paste error :-) )

Again assuming that 'self.childController.stepImage' is a UIImageView then the most likely error is that the name returned by '[database imagefilename]' does not match an image file in the application bundle.

Upvotes: 1

Related Questions