several bindings / KVC fixes

- setValue:forKeyPath will now get call setValue:forKeyPath again on the value of the first part of the key path
- override valueForKeyPath: and valueForKey: in CPObjectController's CPControllerSelectionProxy to return controller markers when appropriate
- override setValue:forKeyPath: and setValue:forKey: in CPObjectController's CPControllerSelectionProxy to bypass possible controller markers

This commit also removes previous hacks for compound paths and adds test cases for the errors. All this is related to issue #967.
This commit is contained in:
Klaas Pieter Annema
2010-11-23 14:18:22 +01:00
parent b49dc87a86
commit 34339fbcd9
4 changed files with 98 additions and 65 deletions
+8 -17
View File
@@ -178,9 +178,6 @@ var CPObjectAccessorsForClassKey = @"$CPObjectAccessorsForClassKey",
remainingKeyPath = aKeyPath.substring(firstDotIndex + 1),
value = [self valueForKey:firstKeyComponent];
if (CPIsControllerMarker(value))
return value;
return [value valueForKeyPath:remainingKeyPath];
}
@@ -213,24 +210,18 @@ var CPObjectAccessorsForClassKey = @"$CPObjectAccessorsForClassKey",
- (void)setValue:(id)aValue forKeyPath:(CPString)aKeyPath
{
if (!aKeyPath) aKeyPath = "self";
if (!aKeyPath) aKeyPath = @"self";
var i = 0,
keys = aKeyPath.split("."),
count = keys.length - 1,
owner = self;
var firstDotIndex = aKeyPath.indexOf(".");
for (; i < count; ++i)
{
var newOwner = [owner valueForKey:keys[i]];
if (firstDotIndex === -1)
return [self setValue:aValue forKey:aKeyPath];
if (CPIsControllerMarker(newOwner))
newOwner = [owner _valueForKey:keys[i]];
var firstKeyComponent = aKeyPath.substring(0, firstDotIndex),
remainingKeyPath = aKeyPath.substring(firstDotIndex + 1),
value = [self valueForKey:firstKeyComponent];
owner = newOwner;
}
[owner setValue:aValue forKey:keys[i]];
return [value setValue:aValue forKeyPath:remainingKeyPath];
}
- (void)setValue:(id)aValue forKey:(CPString)aKey