开发者

Objective C Comparing the name of an UIImageView

开发者 https://www.devze.com 2022-12-17 08:40 出处:网络
i have a question, totally newbie but i would like to know how can i get to compare and image in an if else statement?

i have a question, totally newbie but i would like to know how can i get to compare and image in an if else statement?

i have an image lets say it is 开发者_JAVA百科"img.png" and i have it displayed in an imageview already in the application, however in the codes i would like to compare if the image show is "img.png"

I understand that for string we use the isEqualToString:, so if it's for an image what would i use?

example would be :

if ([img.image isEqual:@"img.png"])

What i've typed is something like this but it isnt working. could anyone point me in the right direction? thanks alot

Much appreciated!


If you first got the image using [UIImage imageNamed:@"img.png"] you could compare the image object pointers: if (img.image == [UIImage imageNamed:@"img.png"]).

But: I'd consider this bad design and would rather use another way of identifying images, like storing the name of the image in another instance variable.

0

精彩评论

暂无评论...
验证码 换一张
取 消