Skip to content

Instantly share code, notes, and snippets.

@dfox
Created August 7, 2012 18:37
Show Gist options
  • Save dfox/3288148 to your computer and use it in GitHub Desktop.
Save dfox/3288148 to your computer and use it in GitHub Desktop.
Adding Properties to UIResponder
#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