Skip to content

Instantly share code, notes, and snippets.

@andrewsardone
Last active December 20, 2015 05:09
Show Gist options
  • Save andrewsardone/6076443 to your computer and use it in GitHub Desktop.
Save andrewsardone/6076443 to your computer and use it in GitHub Desktop.
I'm trying my hardest to make sure @cdzombak can't read this code.
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if (object == self && context == self.kvoContext) {
((void (^)(void)) @{
@"addresses": ^{ self.peep.address = [self dictionaryForArrayOfValues:self.addresses]; },
@"emails": ^{ self.peep.email = [self dictionaryForArrayOfValues:self.emails]; },
}[keyPath] ?: ^{})();
}
else if (object == self.peep && context == self.kvoContext) {
((void (^)(void)) @{
@"address": ^{
_addresses = [self arrayForDictionaryOfValues:self.peep.address
withBackupKey:NSLocalizedString(@"address", nil)];
},
@"email": ^{
_emails = [self arrayForDictionaryOfValues:self.peep.email
withBackupKey:NSLocalizedString(@"email", nil)];
},
}[keyPath] ?: ^{})();
}
else {
[super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment