Created
January 8, 2013 07:46
-
-
Save darknoon/4482025 to your computer and use it in GitHub Desktop.
Safe KVC macro by Andrew Pouliot. In the public domain.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//o is an object type, k is the key on which to check validity | |
//returns a NSString constant of the relevant key | |
#define KVC(o, k) (0 && sizeof(o.k) ? @#k : @#k) | |
//Usage: | |
ObjectWithMethodCalledKeyName *object = ...; | |
[object addObserver:self forKeyPath:KVC(object, keyName) options:0 context:NULL]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment