From 2269eaf1bfb93828cda8201c28e5a6346ca3e8e7 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Fri, 22 Feb 2008 21:21:24 +0000 Subject: [PATCH] Monotone-Parent: 8f8ecd8d738bfaf099722644bfbdaee74d8b589d Monotone-Revision: 8eb1c04a52c5c9e085d3376ba6f9142b007cf6b7 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2008-02-22T21:21:24 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 3 +++ SoObjects/SOGo/NSArray+Utilities.h | 2 ++ SoObjects/SOGo/NSArray+Utilities.m | 15 +++++++++++++++ 3 files changed, 20 insertions(+) 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