Created
March 13, 2017 08:05
-
-
Save joanmolinas/ec8690f5fc08b375e60ff3d705f207ef to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <Foundation/Foundation.h> | |
@interface NSObject (AssociatedObjects) | |
- (void)associatedValue:(id)value withKey:(void *)key; | |
- (id)associatedValueForKey:(void *)key; | |
@en |
This file contains hidden or 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 "NSObject+AssociatedObjects.h" | |
#import <objc/runtime.h> | |
@implementation NSObject (AssociatedObjects) | |
- (void)associatedValue:(id)value withKey:(void *)key { | |
objc_setAssociatedObject(self, key, value, OBJC_ASSOCIATION_RETAIN); | |
} | |
- (id)associatedValueForKey:(void *)key { | |
return objc_getAssociatedObject(self, key); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment