mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-05-05 11:35:26 +00:00
Monotone-Parent: af5a859ee61b26ffd727e648f95c54ee60e3079e
Monotone-Revision: 668c4f876568e36b66e3c665c37e3108a08fb967 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-08-15T19:50:20 Monotone-Branch: ca.inverse.sogo
This commit is contained in:
@@ -1,5 +1,14 @@
|
||||
2007-08-15 Wolfgang Sourdeau <wsourdeau@inverse.ca>
|
||||
|
||||
* SoObjects/SOGo/NSArray+Utilities.m ([NSArray
|
||||
-keysWithFormat:format]): method that forward the method of the
|
||||
same name to each member of the array, considering they all are
|
||||
instances of NSDictionary.
|
||||
([NSArray -objectsForKey:key]): same principle as above.
|
||||
([NSArray -flattenedArray]): new method that transforms an array
|
||||
of arrays into a single array containing all the elements of the
|
||||
subarrays.
|
||||
|
||||
* SoObjects/SOGo/NSDictionary+Utilities.m ([NSDictionary
|
||||
-keysWithFormat:keyFormat]): new method inspired by the python
|
||||
string formatting system and which replaces occurences of "%{key}"
|
||||
|
||||
@@ -32,6 +32,9 @@
|
||||
- (NSString *) jsonRepresentation;
|
||||
|
||||
- (NSArray *) stringsWithFormat: (NSString *) format;
|
||||
- (NSArray *) keysWithFormat: (NSString *) format;
|
||||
- (NSArray *) objectsForKey: (NSString *) key;
|
||||
- (NSArray *) flattenedArray;
|
||||
|
||||
- (BOOL) containsCaseInsensitiveString: (NSString *) match;
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
id currentObject;
|
||||
|
||||
formattedStrings = [NSMutableArray arrayWithCapacity: [self count]];
|
||||
|
||||
objects = [self objectEnumerator];
|
||||
currentObject = [objects nextObject];
|
||||
while (currentObject)
|
||||
@@ -45,6 +46,61 @@
|
||||
return formattedStrings;
|
||||
}
|
||||
|
||||
- (NSArray *) keysWithFormat: (NSString *) format
|
||||
{
|
||||
NSMutableArray *formattedStrings;
|
||||
NSEnumerator *objects;
|
||||
id currentObject;
|
||||
|
||||
formattedStrings = [NSMutableArray arrayWithCapacity: [self count]];
|
||||
|
||||
objects = [self objectEnumerator];
|
||||
currentObject = [objects nextObject];
|
||||
while (currentObject)
|
||||
{
|
||||
[formattedStrings addObject: [currentObject keysWithFormat: format]];
|
||||
currentObject = [objects nextObject];
|
||||
}
|
||||
|
||||
return formattedStrings;
|
||||
}
|
||||
|
||||
- (NSArray *) objectsForKey: (NSString *) key
|
||||
{
|
||||
NSMutableArray *objectsForKey;
|
||||
unsigned int count, max;
|
||||
id value;
|
||||
|
||||
max = [self count];
|
||||
objectsForKey = [NSMutableArray arrayWithCapacity: max];
|
||||
|
||||
for (count = 0; count < max; count++)
|
||||
{
|
||||
value = [[self objectAtIndex: count] objectForKey: key];
|
||||
[objectsForKey addObject: value];
|
||||
}
|
||||
|
||||
return objectsForKey;
|
||||
}
|
||||
|
||||
- (NSArray *) flattenedArray
|
||||
{
|
||||
NSMutableArray *flattenedArray;
|
||||
NSEnumerator *objects;
|
||||
id currentObject;
|
||||
|
||||
flattenedArray = [NSMutableArray array];
|
||||
objects = [self objectEnumerator];
|
||||
currentObject = [objects nextObject];
|
||||
while (currentObject)
|
||||
{
|
||||
[flattenedArray addObjectsFromArray: currentObject];
|
||||
currentObject = [objects nextObject];
|
||||
}
|
||||
|
||||
return flattenedArray;
|
||||
}
|
||||
|
||||
- (void) makeObjectsPerform: (SEL) selector
|
||||
withObject: (id) object1
|
||||
withObject: (id) object2
|
||||
|
||||
Reference in New Issue
Block a user