From 1d623e943aeac1025bc2b94200b9b19fbdea03c9 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Tue, 26 Oct 2010 18:28:22 +0000 Subject: [PATCH] Monotone-Parent: d28c051b2f83062ff54891a804d548e9ca666837 Monotone-Revision: 4e94693f8d0d9bd27638178db0ec3d7df3939ff0 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-10-26T18:28:22 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 4 ++++ SoObjects/SOGo/NSArray+Utilities.h | 2 ++ SoObjects/SOGo/NSArray+Utilities.m | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3be508b09..aa25d4f84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2010-10-26 Wolfgang Sourdeau + * SoObjects/SOGo/NSArray+Utilities.m (-mergedArrayWithArray:): new + method that returns the contact of the current array merged with + a unique copy of the objects of the array passed as parameter. + * SoObjects/SOGo/SOGoUserDefaults.m (-{set}ContactsCategories): renamed version of the "contactCategories" accessors. diff --git a/SoObjects/SOGo/NSArray+Utilities.h b/SoObjects/SOGo/NSArray+Utilities.h index 7917af434..adf773809 100644 --- a/SoObjects/SOGo/NSArray+Utilities.h +++ b/SoObjects/SOGo/NSArray+Utilities.h @@ -57,6 +57,8 @@ /* foreach ... */ - (NSArray *) resultsOfSelector: (SEL) operation; +- (NSArray *) mergedArrayWithArray: (NSArray *) otherArray; + @end @interface NSMutableArray (SOGoArrayUtilities) diff --git a/SoObjects/SOGo/NSArray+Utilities.m b/SoObjects/SOGo/NSArray+Utilities.m index 8d9315ea2..0111c0580 100644 --- a/SoObjects/SOGo/NSArray+Utilities.m +++ b/SoObjects/SOGo/NSArray+Utilities.m @@ -204,6 +204,25 @@ return results; } +- (NSArray *) mergedArrayWithArray: (NSArray *) otherArray +{ + NSMutableArray *mergedArray; + NSUInteger count, max; + id object; + + max = [otherArray count]; + mergedArray = [NSMutableArray arrayWithCapacity: (max + [self count])]; + [mergedArray setArray: self]; + for (count = 0; count < max; count++) + { + object = [otherArray objectAtIndex: count]; + if (![mergedArray containsObject: object]) + [mergedArray addObject: object]; + } + + return mergedArray; +} + - (NSString *) jsonRepresentation { id currentElement;