diff --git a/ChangeLog b/ChangeLog index 6b28ab8fa..88cca91a1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2008-02-22 Wolfgang Sourdeau + * SoObjects/SOGo/NSArray+Utilities.m ([NSArray -uniqueObjects]): + new method that returns unique occurences of the objects. + * SoObjects/Contacts/SOGoContactGCSFolder.m ([SOGoContactGCSFolder -davNamespaces]): same as below. diff --git a/SoObjects/SOGo/NSArray+Utilities.h b/SoObjects/SOGo/NSArray+Utilities.h index 181f636cd..998cab7c8 100644 --- a/SoObjects/SOGo/NSArray+Utilities.h +++ b/SoObjects/SOGo/NSArray+Utilities.h @@ -36,6 +36,8 @@ - (NSArray *) objectsForKey: (NSString *) key; - (NSArray *) flattenedArray; +- (NSArray *) uniqueObjects; + - (BOOL) containsCaseInsensitiveString: (NSString *) match; #ifdef GNUSTEP_BASE_LIBRARY diff --git a/SoObjects/SOGo/NSArray+Utilities.m b/SoObjects/SOGo/NSArray+Utilities.m index 3f5a78b5a..1e63756bf 100644 --- a/SoObjects/SOGo/NSArray+Utilities.m +++ b/SoObjects/SOGo/NSArray+Utilities.m @@ -105,6 +105,21 @@ return flattenedArray; } +- (NSArray *) uniqueObjects +{ + NSMutableArray *newArray; + NSEnumerator *objects; + id currentObject; + + newArray = [NSMutableArray array]; + + objects = [self objectEnumerator]; + while ((currentObject = [objects nextObject])) + [newArray addObjectUniquely: currentObject]; + + return newArray; +} + - (void) makeObjectsPerform: (SEL) selector withObject: (id) object1 withObject: (id) object2