Reputation: 1117
Is it possible to assign a text tag to any UIObject? If not is there another way I can do it? Can I do for example:
image.tag = [NSString stringWithFormat: @"Hello"];
Thanks for any help!
Upvotes: 0
Views: 336
Reputation: 112857
No, the tag is an integer.
Consider subclassing UIImageView
class and just adding a NSString
property. It is really simple these days.
Example:
@interface TaggedImageView : UIImageView
@property (nonatomic, strong) NSString *tagString;
@end
@implementation TaggedImageView
@end
Then just use TaggedImageView
in place of UIImageView
.
If you only access the MyImageView
from one .m file you can just put these lines just after the #import
statements.
Upvotes: 0
Reputation: 11476
The tag property is an NSInteger
- therefore this is not possible.
You can create a subclass and add an NSString
property.
Upvotes: 1