Monotone-Parent: 31a2a168c052c18dcda914f1ebbe5bc651fdd779

Monotone-Revision: b2d46c6b2a5ef48f18ce5b5dae9339ace2025d0d

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2009-11-04T16:26:22
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau 2009-11-04 16:26:22 +00:00
parent 012aad04f8
commit dd6fb4c07d
3 changed files with 17 additions and 20 deletions

View file

@ -1,3 +1,11 @@
2009-11-04 Wolfgang Sourdeau <wsourdeau@inverse.ca>
* SoObjects/SOGo/NSDictionary+Utilities.m
(+dictionaryFromStringsFile:): instantiate autoreleased objects.
* SoObjects/SOGo/NSArray+Utilities.m (-jsonRepresentation):
instantiate autoreleased objects.
2009-10-30 Francis Lachapelle <flachapelle@inverse.ca> 2009-10-30 Francis Lachapelle <flachapelle@inverse.ca>
* UI/WebServerResources/SchedulerUI.js: the events list is now * UI/WebServerResources/SchedulerUI.js: the events list is now

View file

@ -174,18 +174,12 @@
NSEnumerator *elements; NSEnumerator *elements;
NSString *representation; NSString *representation;
jsonElements = [NSMutableArray new]; jsonElements = [NSMutableArray array];
elements = [self objectEnumerator]; elements = [self objectEnumerator];
currentElement = [elements nextObject]; while ((currentElement = [elements nextObject]))
while (currentElement) [jsonElements addObject: [currentElement jsonRepresentation]];
{
[jsonElements addObject: [currentElement jsonRepresentation]];
currentElement = [elements nextObject];
}
representation = [NSString stringWithFormat: @"[%@]", representation = [NSString stringWithFormat: @"[%@]",
[jsonElements componentsJoinedByString: @", "]]; [jsonElements componentsJoinedByString: @", "]];
[jsonElements autorelease];
return representation; return representation;
} }

View file

@ -29,10 +29,11 @@
#import <Foundation/NSCharacterSet.h> #import <Foundation/NSCharacterSet.h>
#import <NGExtensions/NGBase64Coding.h> #import <NGExtensions/NGBase64Coding.h>
#import <SoObjects/SOGo/NSString+Utilities.h>
#import "NSArray+Utilities.h" #import "NSArray+Utilities.h"
#import "NSObject+Utilities.h" #import "NSObject+Utilities.h"
#import "NSString+Utilities.h"
#import "NSDictionary+Utilities.h" #import "NSDictionary+Utilities.h"
@implementation NSDictionary (SOGoDictionaryUtilities) @implementation NSDictionary (SOGoDictionaryUtilities)
@ -43,15 +44,14 @@
NSMutableData *content; NSMutableData *content;
NSDictionary *newDictionary; NSDictionary *newDictionary;
content = [NSMutableData new]; content = [NSMutableData data];
[content appendBytes: "{" length: 1]; [content appendBytes: "{" length: 1];
[content appendData: [NSData dataWithContentsOfFile: file]]; [content appendData: [NSData dataWithContentsOfFile: file]];
[content appendBytes: "}" length: 1]; [content appendBytes: "}" length: 1];
serialized = [[NSString alloc] initWithData: content serialized = [[NSString alloc] initWithData: content
encoding: NSUTF8StringEncoding]; encoding: NSUTF8StringEncoding];
[content release]; [serialized autorelease];
newDictionary = [serialized propertyList]; newDictionary = [serialized propertyList];
[serialized release];
return newDictionary; return newDictionary;
} }
@ -62,20 +62,17 @@
NSString *representation, *currentKey, *currentValue, *currentPair; NSString *representation, *currentKey, *currentValue, *currentPair;
NSEnumerator *keys; NSEnumerator *keys;
values = [NSMutableArray new]; values = [NSMutableArray array];
keys = [[self allKeys] objectEnumerator]; keys = [[self allKeys] objectEnumerator];
currentKey = [keys nextObject]; while ((currentKey = [keys nextObject]))
while (currentKey)
{ {
currentValue = [[self objectForKey: currentKey] jsonRepresentation]; currentValue = [[self objectForKey: currentKey] jsonRepresentation];
currentPair = [NSString stringWithFormat: @"%@: %@", currentPair = [NSString stringWithFormat: @"%@: %@",
[currentKey jsonRepresentation], currentValue]; [currentKey jsonRepresentation], currentValue];
[values addObject: currentPair]; [values addObject: currentPair];
currentKey = [keys nextObject];
} }
representation = [NSString stringWithFormat: @"{%@}", representation = [NSString stringWithFormat: @"{%@}",
[values componentsJoinedByString: @", "]]; [values componentsJoinedByString: @", "]];
[values release];
return representation; return representation;
} }
@ -202,6 +199,4 @@
@" the number of keys."]; @" the number of keys."];
} }
@end @end