Created
December 14, 2013 06:57
-
-
Save mjjimenez/7956352 to your computer and use it in GitHub Desktop.
Add string type tag to UIViews
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface UIView (StringTagAdditions) | |
@property (nonatomic, copy) NSString *stringTag; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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