我試圖在我的UnitTest之外創建我的RKEntityMapping。我擁有的問題是隻有在我的測試中創建它時纔有效。例如,這可以工作:UnitTests的RestKit實體映射不起作用
RKEntityMapping *accountListMapping = [RKEntityMapping mappingForEntityForName:@"CustomerListResponse" inManagedObjectStore:_sut.managedObjectStore];
[accountListMapping addAttributeMappingsFromDictionary:@{@"count": @"pageCount",
@"page": @"currentPage",
@"pages": @"pages"}];
雖然下面現在可以工作。 all to accoutListMapping返回上面使用相同的託管對象庫所示的內容: RKEntityMapping * accountListMapping = [_sut accountListMapping];
當_sut
創建RKEntityMapping
我得到這個錯誤:
<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];
是的,所以提供一個目標對象。 – Wain
如果我創建符合我的測試的映射,它將在我提供目標對象時起作用; RestKit文檔不提供。如果我在不同的類中創建映射並將其作爲返回值傳遞,那麼即使傳入目標對象也不起作用;它找不到任何可映射的值。我認爲這是RK中的一個錯誤。 –
您是否嘗試過調試2個案例?在RestKit谷歌組或github wiki上詢問可能會更好。 – Wain