New: KVC setValue:forKey: now automatically unwraps CPValue.

This corresponds to the same KVC behaviour in Cocoa and is key when decoding cibs with certain properties set to struct values (such as NSSize).
This commit is contained in:
Alexander Ljungberg committed 2013-06-13 13:20:22 +01:00
1 parent fe79628034
commit bf94dd3a6e
2 files changed
+51

No files matched your search

+6
View File
@@ -187,6 +187,12 @@ var CPObjectAccessorsForClassKey = @"$CPObjectAccessorsForClassKey",
- (void)setValue:(id)aValue forKey:(CPString)aKey
{
// setValue:forKey: should unwrap CPValue by default. In Objective-C we would need to care about which type
// the setter takes (or target ivar) and send [aValue rectValue], [aValue pointValue] etc, but in
// Objective-C we can use them interchangably.
if (aValue && aValue.isa && [aValue isKindOfClass:CPValue])
aValue = [aValue JSObject];
var theClass = [self class],
modifier = nil,
modifiers = theClass[CPObjectModifiersForClassKey];