Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -276,11 +276,25 @@ return [self objectAtIndex: index]; } - (id)valueForKey: (OFString*)key { - OFMutableArray *ret = [OFMutableArray arrayWithCapacity: [self count]]; + OFMutableArray *ret; + + if ([key hasPrefix: @"@"]) { + void *pool = objc_autoreleasePoolPush(); + id ret; + + key = [key substringWithRange: of_range(1, [key length] - 1)]; + ret = [[super valueForKey: key] retain]; + + objc_autoreleasePoolPop(pool); + + return [ret autorelease]; + } + + ret = [OFMutableArray arrayWithCapacity: [self count]]; for (id object in self) { id value = [object valueForKey: key]; if (value == nil) @@ -295,10 +309,21 @@ } - (void)setValue: (id)value forKey: (OFString*)key { + if ([key hasPrefix: @"@"]) { + void *pool = objc_autoreleasePoolPush(); + + key = [key substringWithRange: of_range(1, [key length] - 1)]; + [super setValue: value + forKey: key]; + + objc_autoreleasePoolPop(pool); + return; + } + if (value == [OFNull null]) value = nil; for (id object in self) [object setValue: value Index: tests/OFArrayTests.m ================================================================== --- tests/OFArrayTests.m +++ tests/OFArrayTests.m @@ -324,11 +324,13 @@ TEST(@"-[valueForKey:]", [[[OFArray arrayWithObjects: @"foo", @"bar", @"quxqux", nil] valueForKey: @"length"] isEqual: [OFArray arrayWithObjects: [OFNumber numberWithSize: 3], - [OFNumber numberWithSize: 3], [OFNumber numberWithSize: 6], nil]]) + [OFNumber numberWithSize: 3], [OFNumber numberWithSize: 6], nil]] && + [[[OFArray arrayWithObjects: @"1", @"2", nil] + valueForKey: @"@count"] isEqual: [OFNumber numberWithSize: 2]]) m[0] = [OFMutableArray arrayWithObjects: [OFURL URLWithString: @"http://foo.bar/"], [OFURL URLWithString: @"http://bar.qux/"], [OFURL URLWithString: @"http://qux.quxqux/"], nil];