Created
August 7, 2012 18:37
-
-
Save dfox/3288148 to your computer and use it in GitHub Desktop.
Adding Properties to UIResponder
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 "UIResponder+EventInterceptor.h" | |
#import <objc/runtime.h> | |
const char *ASSOC_OBJECT_EVENT_TYPE = "eventType"; | |
const char *ASSOC_OBJECT_EVENT_VALUE = "eventValue"; | |
@implementation UIResponder (EventInterceptor) | |
-(void) setEventValue:(NSString *)eventValue | |
{ | |
objc_setAssociatedObject (self, ASSOC_OBJECT_EVENT_VALUE, eventValue, OBJC_ASSOCIATION_RETAIN); | |
} | |
-(NSString *) eventValue | |
{ | |
return (NSString *) objc_getAssociatedObject(self, ASSOC_OBJECT_EVENT_VALUE); | |
} | |
-(void) setEventType:(NSString *)eventType | |
{ | |
objc_setAssociatedObject (self, ASSOC_OBJECT_EVENT_TYPE, eventType, OBJC_ASSOCIATION_RETAIN); | |
} | |
-(NSString *) eventType | |
{ | |
return (NSString *) objc_getAssociatedObject(self, ASSOC_OBJECT_EVENT_TYPE); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment