Skip to content

Instantly share code, notes, and snippets.

@krzysztofzablocki
Created August 9, 2012 16:06
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krzysztofzablocki/3305468 to your computer and use it in GitHub Desktop.
Save krzysztofzablocki/3305468 to your computer and use it in GitHub Desktop.
UITableViewCell + representedObject
// Created by Krzysztof Zabłocki
@interface UITableViewCell (representedObject)
@property (nonatomic, strong) id representedObject;
@end
#import "UITableViewCell+representedObject.h"
#import <objc/runtime.h>
static char RepresentedObjectKey;
@implementation UITableViewCell (representedObject)
- (id)representedObject
{
return objc_getAssociatedObject(self, &RepresentedObjectKey);
}
- (void)setRepresentedObject:(id)representedObject
{
objc_setAssociatedObject(self, &RepresentedObjectKey, representedObject, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment