Monotone-Parent: 04980f497e9c317b4d93db9ab0dae2f1e8e464ba

Monotone-Revision: af5a859ee61b26ffd727e648f95c54ee60e3079e

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2007-08-15T19:48:35
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2007-08-15 19:48:35 +00:00
parent 8e42f79fd2
commit a37f85fba7
3 changed files with 32 additions and 0 deletions

View File

@@ -1,3 +1,10 @@
2007-08-15 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/SOGo/NSDictionary+Utilities.m ([NSDictionary
-keysWithFormat:keyFormat]): new method inspired by the python
string formatting system and which replaces occurences of "%{key}"
by the corresponding keys.
2007-08-13 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* Main/SOGo.m ([SOGo -run]): check for channel-type specific

View File

@@ -30,6 +30,7 @@
@interface NSDictionary (SOGoDictionaryUtilities)
- (NSString *) jsonRepresentation;
- (NSString *) keysWithFormat: (NSString *) keyFormat;
@end

View File

@@ -23,6 +23,7 @@
#import <Foundation/NSArray.h>
#import <Foundation/NSString.h>
#import "NSArray+Utilities.h"
#import "NSObject+Utilities.h"
#import "NSDictionary+Utilities.h"
@@ -52,4 +53,27 @@
return representation;
}
- (NSString *) keysWithFormat: (NSString *) keyFormat
{
NSArray *keys, *allKeys;
unsigned int count, max;
NSMutableString *keysWithFormat;
id value;
keysWithFormat = [NSMutableString stringWithString: keyFormat];
allKeys = [self allKeys];
keys = [allKeys stringsWithFormat: @"%{%@}"];
max = [allKeys count];
for (count = 0; count < max; count++)
{
value = [self objectForKey: [allKeys objectAtIndex: count]];
[keysWithFormat replaceString: [keys objectAtIndex: count]
withString: [value description]];
}
return keysWithFormat;
}
@end