Skip to content

Instantly share code, notes, and snippets.

@pier-oliviert
Created October 13, 2010 01:49
Show Gist options
  • Save pier-oliviert/623273 to your computer and use it in GitHub Desktop.
Save pier-oliviert/623273 to your computer and use it in GitHub Desktop.
@implementation MyCellView
- (void)setProfile:(Profile *)p
{
if (profile)
{
[profile removeObserver:self forKeyPath:@"image"];
}
if (p)
{
profile = p;
[profile addObserver:self forKeyPath:@"image" options:NSKeyValueObservingOptionNew context:nil];
}
}
- (void)drawRect:(CGRect)rect
{
//Draw your stuff here.
}
- (void)dealloc
{
self.profile = nil;
[super dealloc];
}
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
[self setNeedsDisplay];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment