view.tag is only stored NSInteger Value.
so, how to identify each view with NSString Value?
not avaliable?
some example:
view0.stringTag = @"basic";
view1.stringTag = @"advanced";
There's no stringTag
property on UIView
. If you need to do this kind of thing you can use a category on UIView
and store the tag in an associated object:
@interface UIView (StringTagAdditions)
@property (nonatomic, copy) NSString *stringTag;
@end
@implementation UIView (StringTagAdditions)
static NSString *kStringTagKey = @"StringTagKey";
- (NSString *)stringTag
{
return objc_getAssociatedObject(self, kStringTagKey);
}
- (void)setStringTag:(NSString *)stringTag
{
objc_setAssociatedObject(self, kStringTagKey, stringTag, OBJC_ASSOCIATION_COPY_NONATOMIC);
}
@end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With