I want my program to be like this
if ([UIImageViewObject identifier]==@"heyItsMeYeaCoolDude")
{
do some methods
}
Whenever I do this though my programs crashes saying:
2012-07-29 19:09:58.401 Bridges[2711:f803] -[UIImageView identifier]: unrecognized selector sent to instance 0x8874f70
With a bunch of crap after it.
In my storyboard, I typed heyItsMeYeaCoolDude under label in the identity inspector, and now my program is complaining.
I know I could use tags also, but I’m already using my images tag for something else, help!
In response to the suggestion you made in the comment below your question, @ownageGuy, an answer to the question you pose:
You’re welcome to subclass anything you like. Subclassing
UIImageViewis a perfectly acceptable solution to this problem. You might also consider the container pattern; ie. create a class which contains an instance of aUIImageViewand anNSStringfor the identifier. Then even if there did happen to be a detriment to subclassingUIImageView, as you fear, it would be eliminated.Then you create an object of type
UIImageViewContainer, setimgViewto the appropriateUIImageView, and store the identifier string insideidentifier.