我正在尝试在我的 UnitTest 之外创建我的 RKEntityMapping。我遇到的问题是它只有在我在测试中创建它时才有效。例如,这有效:
RKEntityMapping *accountListMapping = [RKEntityMapping mappingForEntityForName:@"CustomerListResponse" inManagedObjectStore:_sut.managedObjectStore];
[accountListMapping addAttributeMappingsFromDictionary:@{@"count": @"pageCount",
@"page": @"currentPage",
@"pages": @"pages"}];
虽然以下内容现在可以工作。all to accoutListMapping 使用相同的托管对象存储完全返回上面显示的内容: RKEntityMapping *accountListMapping = [_sut accountListMapping];
在RKEntityMapping
中创建时,_sut
我收到此错误:
<unknown>:0: error: -[SBAccountTests testAccountListFetch] : 0x9e9cd10: failed with error:
Error Domain=org.restkit.RestKit.ErrorDomain Code=1007 "Cannot perform a mapping operation
with a nil destination object." UserInfo=0x8c64490 {NSLocalizedDescription=Cannot perform
a mapping operation with a nil destination object.}
我假设nil
它所指的目标对象是destinationObject:nil
.
RKMappingTest *maptest = [RKMappingTest testForMapping:accountListMapping
sourceObject:_parsedJSON
destinationObject:nil];