Index: src/OFObject+KeyValueCoding.m ================================================================== --- src/OFObject+KeyValueCoding.m +++ src/OFObject+KeyValueCoding.m @@ -50,10 +50,11 @@ if (typeEncoding == NULL) return [self valueForUndefinedKey: key]; switch (nextType(&typeEncoding)) { case '@': + case '#': ret = [self performSelector: selector]; break; #define CASE(encoding, type, method) \ case encoding: \ { \ @@ -139,10 +140,11 @@ return; } switch (valueType) { case '@': + case '#': { void (*setter)(id, SEL, id) = (void(*)(id, SEL, id)) [self methodForSelector: selector]; setter(self, selector, value); } Index: tests/OFObjectTests.m ================================================================== --- tests/OFObjectTests.m +++ tests/OFObjectTests.m @@ -34,11 +34,12 @@ static OFString *module = @"OFObject"; @interface MyObj: OFObject { - id _object; + id _objectValue; + Class _classValue; bool _boolValue; char _charValue; short _shortValue; int _intValue; long _longValue; @@ -50,11 +51,12 @@ unsigned long long _unsignedLongLongValue; float _floatValue; double _doubleValue; } -@property (retain) id object; +@property (retain) id objectValue; +@property Class classValue; @property bool boolValue; @property char charValue; @property short shortValue; @property int intValue; @property long longValue; @@ -67,11 +69,12 @@ @property float floatValue; @property double doubleValue; @end @implementation MyObj -@synthesize object = _object, boolValue = _boolValue, charValue = _charValue; +@synthesize objectValue = _objectValue, classValue = _classValue; +@synthesize boolValue = _boolValue, charValue = _charValue; @synthesize shortValue = _shortValue, intValue = _intValue; @synthesize longValue = _longValue, longLongValue = _longLongValue; @synthesize unsignedCharValue = _unsignedCharValue; @synthesize unsignedShortValue = _unsignedShortValue; @synthesize unsignedIntValue = _unsignedIntValue; @@ -79,11 +82,11 @@ @synthesize unsignedLongLongValue = _unsignedLongLongValue; @synthesize floatValue = _floatValue, doubleValue = _doubleValue; - (void)dealloc { - [_object release]; + [_objectValue release]; [super dealloc]; } @end @@ -146,20 +149,27 @@ [[o description] isEqual: [OFString stringWithFormat: @"", o]] && [[m description] isEqual: [OFString stringWithFormat: @"", m]]) - [m setObject: @"Hello"]; + [m setObjectValue: @"Hello"]; + [m setClassValue: [m class]]; TEST(@"-[valueForKey:]", - [[m valueForKey: @"object"] isEqual: @"Hello"]) + [[m valueForKey: @"objectValue"] isEqual: @"Hello"] && + [[m valueForKey: @"classValue"] isEqual: [m class]] && + [[m valueForKey: @"class"] isEqual: [m class]]) EXPECT_EXCEPTION(@"-[valueForKey:] with undefined key", OFUndefinedKeyException, [m valueForKey: @"undefined"]) TEST(@"-[setValue:forKey:]", R([m setValue: @"World" - forKey: @"object"]) && [[m object] isEqual: @"World"]) + forKey: @"objectValue"]) && + R([m setValue: [OFObject class] + forKey: @"classValue"]) && + [[m objectValue] isEqual: @"World"] && + [[m classValue] isEqual: [OFObject class]]) EXPECT_EXCEPTION(@"-[setValue:forKey:] with undefined key", OFUndefinedKeyException, [m setValue: @"x" forKey: @"undefined"])