Skip to content

Instantly share code, notes, and snippets.

@nicpro85
Created September 10, 2013 18:24
Show Gist options
  • Save nicpro85/6513438 to your computer and use it in GitHub Desktop.
Save nicpro85/6513438 to your computer and use it in GitHub Desktop.
UIButton+IndexPath
#import <UIKit/UIKit.h>
@interface UIButton (IndexPath)
@property (strong, nonatomic) NSIndexPath * indexPath;
@end
#import "UIButton+IndexPath.h"
#import <objc/runtime.h>
static char MyCustomPropertyKey = 0;
@implementation UIButton (IndexPath)
@dynamic indexPath;
- (NSIndexPath *)indexPath
{
return objc_getAssociatedObject(self, &MyCustomPropertyKey);
}
- (void)setIndexPath:(NSIndexPath *)indexPath
{
objc_setAssociatedObject(self, &MyCustomPropertyKey, indexPath, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment