Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thomaswhyyou/29664091b7b6d649f8fc to your computer and use it in GitHub Desktop.
Save thomaswhyyou/29664091b7b6d649f8fc to your computer and use it in GitHub Desktop.
#import <UIKit/UIKit.h>
@interface UIView (StringTagAdditions)
@property (nonatomic, copy) NSString *stringTag;
@end
#import "UIView+StringTagAdditions.h"
#import <objc/runtime.h>
@implementation UIView (StringTagAdditions)
static NSString *kStringTagKey = @"StringTagKey";
- (NSString *)stringTag
{
return (NSString*) objc_getAssociatedObject(self, CFBridgingRetain(kStringTagKey));
}
- (void)setStringTag:(NSString *)stringTag
{
objc_setAssociatedObject(self, CFBridgingRetain(kStringTagKey), stringTag, OBJC_ASSOCIATION_COPY_NONATOMIC);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment