Fixing more memory leaks

This commit is contained in:
Blake Watters
2011-06-20 15:03:35 -04:00
parent 99ae37037a
commit 0954d4a063
5 changed files with 20 additions and 21 deletions

View File

@@ -135,16 +135,18 @@
NSAssert(mapping != nil, @"Cannot map without a mapping to consult");
NSArray* objectsToMap = mappableObjects;
// If we have forced mapping of a dictionary, map each subdictionary
if (mapping.forceCollectionMapping && [mappableObjects isKindOfClass:[NSDictionary class]]) {
RKLogDebug(@"Collection mapping forced for NSDictionary, mapping each key/value independently...");
objectsToMap = [NSMutableArray arrayWithCapacity:[mappableObjects count]];
for (id key in mappableObjects) {
NSDictionary* dictionaryToMap = [NSDictionary dictionaryWithObject:[mappableObjects valueForKey:key] forKey:key];
[(NSMutableArray*)objectsToMap addObject:dictionaryToMap];
if (mapping.forceCollectionMapping) {
// If we have forced mapping of a dictionary, map each subdictionary
if ([mappableObjects isKindOfClass:[NSDictionary class]]) {
RKLogDebug(@"Collection mapping forced for NSDictionary, mapping each key/value independently...");
objectsToMap = [NSMutableArray arrayWithCapacity:[mappableObjects count]];
for (id key in mappableObjects) {
NSDictionary* dictionaryToMap = [NSDictionary dictionaryWithObject:[mappableObjects valueForKey:key] forKey:key];
[(NSMutableArray*)objectsToMap addObject:dictionaryToMap];
}
} else {
RKLogWarning(@"Collection mapping forced but mappable objects is of type '%@' rather than NSDictionary", NSStringFromClass([mappableObjects class]));
}
} else {
RKLogWarning(@"Collection mapping forced but mappable objects is of type '%@' rather than NSDictionary", NSStringFromClass([mappableObjects class]));
}
// Ensure we are mapping onto a mutable collection if there is a target

View File

@@ -186,6 +186,7 @@ extern NSString* const RKObjectMappingNestingAttributeKeyName;
nestedMapping.sourceKeyPath = [nestedMapping.sourceKeyPath stringByReplacingOccurrencesOfString:searchString withString:replacementString];
nestedMapping.destinationKeyPath = [nestedMapping.destinationKeyPath stringByReplacingOccurrencesOfString:searchString withString:replacementString];
[array addObject:nestedMapping];
[nestedMapping release];
}
return array;
@@ -331,7 +332,7 @@ extern NSString* const RKObjectMappingNestingAttributeKeyName;
// If the relationship has changed, set it
if ([self shouldSetValue:destinationObject atKeyPath:mapping.destinationKeyPath]) {
RKLogTrace(@"Mapped relationship object from keyPath '%@' to '%@'. Value: %@", mapping.sourceKeyPath, mapping.destinationKeyPath, destinationObject);
[self.destinationObject setValue:destinationObject forKey:mapping.destinationKeyPath];
[self.destinationObject setValue:destinationObject forKey:mapping.destinationKeyPath];
}
}