@@ -25,10 +25,11 @@ #import "OFArray_subarray.h" #import "OFArray_adjacent.h" #import "OFString.h" #import "OFXMLElement.h" #import "OFDataArray.h" +#import "OFNull.h" #import "OFEnumerationMutationException.h" #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" @@ -272,10 +273,39 @@ - (id)objectAtIndexedSubscript: (size_t)index { return [self objectAtIndex: index]; } + +- (id)valueForKey: (OFString*)key +{ + OFMutableArray *ret = [OFMutableArray arrayWithCapacity: [self count]]; + + for (id object in self) { + id value = [object valueForKey: key]; + + if (value == nil) + value = [OFNull null]; + + [ret addObject: value]; + } + + [ret makeImmutable]; + + return ret; +} + +- (void)setValue: (id)value + forKey: (OFString*)key +{ + if (value == [OFNull null]) + value = nil; + + for (id object in self) + [object setValue: value + forKey: key]; +} - (size_t)indexOfObject: (id)object { size_t i = 0;