mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-09 10:20:59 +00:00
Fix two problems with KVC:
- valueForKeyPath: looped over individual components, which meant classes couldn't override valueForKeyPath: to do multi-part keys (needed for operators) - CPArray's valueForKeyPath: implementation was incorrectly parsing the operator if it was a simple key
This commit is contained in:
1 parent
72c36789c6
commit
da84964a33
3 files changed
+28
-16
No files matched your search
@@ -174,17 +174,16 @@ CPUnknownUserInfoKey = @"CPUnknownUserInfoKey";
|
||||
|
||||
- (id)valueForKeyPath:(CPString)aKeyPath
|
||||
{
|
||||
var keys = aKeyPath.split("."),
|
||||
|
||||
index = 0,
|
||||
count = keys.length,
|
||||
|
||||
value = self;
|
||||
var firstDotIndex = aKeyPath.indexOf(".");
|
||||
|
||||
for(; index < count; ++index)
|
||||
value = [value valueForKey:keys[index]];
|
||||
if (firstDotIndex === -1)
|
||||
return [self valueForKey:aKeyPath];
|
||||
|
||||
return value;
|
||||
var firstKeyComponent = aKeyPath.substring(0, firstDotIndex),
|
||||
remainingKeyPath = aKeyPath.substring(firstDotIndex+1),
|
||||
value = [self valueForKey:firstKeyComponent];
|
||||
|
||||
return [value valueForKeyPath:remainingKeyPath];
|
||||
}
|
||||
|
||||
- (CPDictionary)dictionaryWithValuesForKeys:(CPArray)keys
|
||||
|
||||
Reference in new issue
Block a user