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;