From f5d379ada0bec3f2e89353915936a234be78eb17 Mon Sep 17 00:00:00 2001 From: Quentin Mathe Date: Mon, 20 Jan 2014 17:45:23 +0000 Subject: [PATCH] Added missing method -valueForKey: in NSSet git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@37624 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++++ Source/NSSet.m | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) 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;