Created
December 19, 2010 20:29
-
-
Save cacaodev/747664 to your computer and use it in GitHub Desktop.
Return a KVC proxy if the receiver implements -countOfKey AND objectInKeyAtIndex:
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
- (id)valueForKey:(CPString)aKey | |
{ | |
var capitalizedKey = aKey.charAt(0).toUpperCase() + aKey.substring(1), | |
objectAtIndexSEL = sel_getName(@"objectIn" + capitalizedKey + "AtIndex:"), | |
objectsAtIndexesSEL = sel_getName(aKey + "AtIndexes:"), | |
countSEL = sel_getName(@"countOf" + capitalizedKey); | |
if ([destination respondsToSelector:countSEL] && ([destination respondsToSelector:objectAtIndexSEL] || [destination respondsToSelector:objectsAtIndexesSEL])) | |
return [destination mutableArrayValueForKey:aKey]; | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment