mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-28 20:55:32 +08:00
Don't throw an exception if doing a simple attribute mapping with a nil data source. closes #1005
This commit is contained in:
@@ -650,7 +650,7 @@ static void RKSetIntermediateDictionaryValuesOnObjectForKeyPath(id object, NSStr
|
|||||||
|
|
||||||
[self applyNestedMappings];
|
[self applyNestedMappings];
|
||||||
BOOL mappedSimpleAttributes = [self applyAttributeMappings:[self simpleAttributeMappings]];
|
BOOL mappedSimpleAttributes = [self applyAttributeMappings:[self simpleAttributeMappings]];
|
||||||
BOOL mappedRelationships = [self applyRelationshipMappings];
|
BOOL mappedRelationships = [[self relationshipMappings] count] ? [self applyRelationshipMappings] : NO;
|
||||||
BOOL mappedKeyPathAttributes = [self applyAttributeMappings:[self keyPathAttributeMappings]];
|
BOOL mappedKeyPathAttributes = [self applyAttributeMappings:[self keyPathAttributeMappings]];
|
||||||
if ((mappedSimpleAttributes || mappedKeyPathAttributes || mappedRelationships) && _validationError == nil) {
|
if ((mappedSimpleAttributes || mappedKeyPathAttributes || mappedRelationships) && _validationError == nil) {
|
||||||
RKLogDebug(@"Finished mapping operation successfully...");
|
RKLogDebug(@"Finished mapping operation successfully...");
|
||||||
|
|||||||
@@ -490,4 +490,24 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)testMappingSimpleAttributesDoesNotTriggerDataSourceAssertion
|
||||||
|
{
|
||||||
|
RKObjectMapping *mapping = [RKObjectMapping mappingForClass:[NSMutableDictionary class]];
|
||||||
|
[mapping addAttributeMappingsFromArray:@[@"boolString"]];
|
||||||
|
TestMappable *object = [TestMappable new];
|
||||||
|
object.boolString = @"test";
|
||||||
|
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
|
||||||
|
RKMappingOperation *operation = [[RKMappingOperation alloc] initWithSourceObject:object destinationObject:dictionary mapping:mapping];
|
||||||
|
NSException *exception = nil;
|
||||||
|
@try {
|
||||||
|
[operation start];
|
||||||
|
}
|
||||||
|
@catch (NSException *e) {
|
||||||
|
exception = e;
|
||||||
|
}
|
||||||
|
@finally {
|
||||||
|
expect(exception).to.beNil();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
Reference in New Issue
Block a user