Mahesh Babu
Mahesh Babu

Reputation: 3433

how can i assign image name to string variable

I am new to iPhone. What i need is i have to assign image name (eg.parrot.jpg) to NSString value.i need to display image in imageview using this string variable.

apporxmatly imageview.image = NSStringvarible; where NSStringVArible is image name.

How can i done this?

Upvotes: 0

Views: 971

Answers (3)

Ratan
Ratan

Reputation: 1757

NSString *imageName = @"parrot.jpg";

UIImageView *view = [[UIImageView alloc]initWithImage:[UIImage imageNamed:imageName]];

Upvotes: 2

Suresh Varma
Suresh Varma

Reputation: 9740

You can use

imageview.image = [UIImage imageNamed:NSStringvarible];

as imageview.image needs image and not simple string... So you line will give you warning and will terminate the application Use the above line will help you solve the problem...

hAPPY iCODING...

Upvotes: 0

LarsJK
LarsJK

Reputation: 2196

youreImageView.image = [UIImage imageNamed:@"parrot.jpg"];

Upvotes: 0

Related Questions