Reputation: 741
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!
Upvotes: 1
Views: 78
Reputation: 4373
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 UIImageView
is a perfectly acceptable solution to this problem. You might also consider the container pattern; ie. create a class which contains an instance of a UIImageView
and an NSString
for the identifier. Then even if there did happen to be a detriment to subclassing UIImageView
, as you fear, it would be eliminated.
@interface UIImageViewContainer : NSObject
{
UIImageView* imgView;
NSString* identifier;
}
Then you create an object of type UIImageViewContainer
, set imgView
to the appropriate UIImageView
, and store the identifier string inside identifier
.
Upvotes: 1