Skip to content

Instantly share code, notes, and snippets.

@fengb
Last active August 29, 2015 14:20
Show Gist options
  • Save fengb/fc1cf780923890426c83 to your computer and use it in GitHub Desktop.
Save fengb/fc1cf780923890426c83 to your computer and use it in GitHub Desktop.
KVO context hack
#define CLASS_KVO_CONTEXT ((__bridge void *)[self class])
[_quote addObserver:self forKeyPath:@"bid" options:0 context:CLASS_KVO_CONTEXT];
#define CLASS_KVO_CONTEXT(instance) ((__bridge void *)[instance class])
[_quote addObserver:self forKeyPath:@"bid" options:0 context:CLASS_KVO_CONTEXT(self)];
#define KVO_CONTEXT(instance) ((__bridge void *)[instance class])
[_quote addObserver:self forKeyPath:@"bid" options:0 context:KVO_CONTEXT([self class])];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment