diff --git a/ChangeLog b/ChangeLog index aebb81113..9d5490914 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-01-20 Quentin Mathe + + * Source/NSSet.m (-valueForKey:): Added missing method (-valueForKeyPath: + is already implemented). + 2014-01-20 Quentin Mathe * Source/NSKeyValueMutableArray.m: diff --git a/Source/NSSet.m b/Source/NSSet.m index ad883547c..40f90eb67 100644 --- a/Source/NSSet.m +++ b/Source/NSSet.m @@ -625,6 +625,24 @@ static Class NSMutableSet_concrete_class; return [[self allObjects] descriptionWithLocale: locale]; } +- (id) valueForKey: (NSString*)key +{ + NSEnumerator *e = [self objectEnumerator]; + id object = nil; + NSMutableSet *results = [NSMutableSet setWithCapacity: [self count]]; + + while ((object = [e nextObject]) != nil) + { + id result = [object valueForKey: key]; + + if (result == nil) + continue; + + [results addObject: result]; + } + return results; +} + - (id) valueForKeyPath: (NSString*)path { id result = (id) nil;