mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-23 04:20:21 +08:00
Fixing more memory leaks
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user