我的restKit /核心数据存在问题。我在没有使用核心数据的情况下使用了app。一切都很好。但是当我在核心数据轨道上翻译所有内容时,我的应用程序开始下降有些搜索让我想到relationshipMappingFromKeyPath
中的问题,因为如果没有这一切,一切都会完美无缺。
我的代码:
NSString *URLPath = [NSString stringWithFormat:@"/v1/projects/%ld/tasks", projectId];
NSDictionary *mappingDictionary = @{
@"id" : @"taskId",
@"attrs.state" : @"state",
@"attrs.priority" : @"priority",
@"attrs.title" : @"title",
@"attrs.createdAt" : @"createdAt",
@"attrs.finishedAt" : @"finishedAt",
@"attrs.problem" : @"problem",
@"attrs.solution" : @"solution",
@"attrs.spent" : @"spent",
@"attrs.complete" : @"complete"
};
NSDictionary *taskSolutionDictionary = @{
@"fileName" : @"fileName",
@"URL" : @"urlString",
};
RKEntityMapping *taskMapping = [RKEntityMapping mappingForEntityForName:@"SMTask"
inManagedObjectStore:[[RKObjectManager sharedManager] managedObjectStore]];
[taskMapping addAttributeMappingsFromDictionary:mappingDictionary];
RKEntityMapping *taskSolutionMapping = [RKEntityMapping mappingForEntityForName:@"SMTaskSolutionFile"
inManagedObjectStore:[[RKObjectManager sharedManager] managedObjectStore]];
[taskSolutionMapping addAttributeMappingsFromDictionary:taskSolutionDictionary];
[taskMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"related.subtasks"
toKeyPath:@"subTasks"
withMapping:taskMapping]];
[taskMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"attrs.solutionFiles"
toKeyPath:@"solutionFiles"
withMapping:taskSolutionMapping]];
NSIndexSet *statusCodes = RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful);
RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:taskMapping
method:RKRequestMethodAny
pathPattern:URLPath
keyPath:@"data"
statusCodes:statusCodes];
[[RKObjectManager sharedManager] addResponseDescriptor:responseDescriptor];
NSMutableDictionary *resultParams = [NSMutableDictionary dictionaryWithObject:@(page) forKey:@"page"];
[resultParams addEntriesFromDictionary:params];
但每次我都有这个错误:
2016-06-16 18:31:27.286 InterLabs [53443:10207583]我 restkit.network:RKObjectRequestOperation.m:137 GET https://api.interlabs.pro/v1/projects/3o7/tasks?page=1 2016-06-16 18:31:27.351 InterLabs [53443:10207568]我 restkit.core_data:RKInMemoryManagedObjectCache.m:94缓存实例 实体' SMTask'按属性' taskId' 2016-06-16 18:31:27.578 InterLabs [53443:10207568] W restkit.core_data:RKManagedObjectMappingOperationDataSource.m:286 托管对象缓存为配置的标识符返回了9个对象 对于' SMTask'实体,预期1. 2016-06-16 18:31:27.580 InterLabs [53443:10207568] W restkit.core_data:RKManagedObjectMappingOperationDataSource.m:286 托管对象缓存为配置的标识符返回了9个对象 对于' SMTask'实体,预期1. 2016-06-16 18:31:27.582 InterLabs [53443:10207568] W restkit.core_data:RKManagedObjectMappingOperationDataSource.m:286 托管对象缓存为配置的标识符返回了9个对象 对于' SMTask'实体,预期1. 2016-06-16 18:31:27.587 InterLabs [53443:10207568] W restkit.core_data:RKManagedObjectMappingOperationDataSource.m:286 托管对象缓存为配置的标识符返回了9个对象 对于' SMTask'实体,预期1. 2016-06-16 18:31:27.590 InterLabs [53443:10207568] W restkit.core_data:RKManagedObjectMappingOperationDataSource.m:286 托管对象缓存为配置的标识符返回了9个对象 对于' SMTask'实体,预期1. 2016-06-16 18:31:27.590 InterLabs [53443:10207568] W restkit.core_data:RKManagedObjectMappingOperationDataSource.m:286 托管对象缓存为配置的标识符返回了9个对象 对于' SMTask'实体,预期1. 2016-06-16 18:31:27.591 InterLabs [53443:10207568] W restkit.core_data:RKManagedObjectMappingOperationDataSource.m:286 托管对象缓存为配置的标识符返回了9个对象 对于' SMTask'实体,预期1. 2016-06-16 18:31:27.592 InterLabs [53443:10207568] W restkit.core_data:RKManagedObjectMappingOperationDataSource.m:286 托管对象缓存为配置的标识符返回了9个对象 对于' SMTask'实体,预期1. 2016-06-16 18:31:27.594 InterLabs [53443:10207568] W restkit.core_data:RKManagedObjectMappingOperationDataSource.m:286 托管对象缓存为配置的标识符返回了9个对象 对于' SMTask'实体,预期1. 2016-06-16 18:31:27.595 InterLabs [53443:10207568] W restkit.core_data:RKManagedObjectMappingOperationDataSource.m:286 托管对象缓存为配置的标识符返回了9个对象 对于' SMTask'实体,预期1. 2016-06-16 18:31:27.596 InterLabs [53443:10207568] W restkit.core_data:RKManagedObjectMappingOperationDataSource.m:286 托管对象缓存为配置的标识符返回了9个对象 对于' SMTask'实体,预期1. 2016-06-16 18:31:27.597 InterLabs [53443:10207568] W restkit.core_data:RKManagedObjectMappingOperationDataSource.m:286 托管对象缓存为配置的标识符返回了9个对象 对于' SMTask'实体,预期1. 2016-06-16 18:31:27.621 InterLabs [53443:10207568] W restkit.core_data:RKManagedObjectMappingOperationDataSource.m:286 托管对象缓存为配置的标识符返回了9个对象 对于' SMTask'实体,预期1. 2016-06-16 18:31:27.622 InterLabs [53443:10207568] W restkit.core_data:RKManagedObjectMappingOperationDataSource.m:286 托管对象缓存为配置的标识符返回了9个对象 对于' SMTask'实体,预期1. 2016-06-16 18:31:27.624 InterLabs [53443:10207568] W restkit.core_data:RKManagedObjectMappingOperationDataSource.m:286 托管对象缓存为配置的标识符返回了9个对象 对于' SMTask'实体,预期1. 2016-06-16 18:31:27.629 InterLabs [53443:10207568] W restkit.core_data:RKManagedObjectMappingOperationDataSource.m:286 托管对象缓存为配置的标识符返回了9个对象 对于' SMTask'实体,预期1. 2016-06-16 18:31:27.631 InterLabs [53443:10207568] W restkit.core_data:RKManagedObjectMappingOperationDataSource.m:286 托管对象缓存为配置的标识符返回了9个对象 对于' SMTask'实体,预期1。
*由于未捕获的异常终止应用程序' NSInvalidArgumentException',原因:' - [__ NSCFBoolean isDeleted]:无法识别的选择器发送到实例0x108860420' * 第一次抛出调用堆栈: ( 0 CoreFoundation 0x00000001085b6f35 exceptionPreprocess + 165 1 libobjc.A.dylib 0x0000000108251bb7 objc_exception_throw + 45 2 CoreFoundation 0x00000001085be04d - [NSObject(NSObject)doesNotRecognizeSelector:] + 205 3 CoreFoundation 0x000000010851627c ___ forwarding _ + 988 4 CoreFoundation 0x0000000108515e18 _CF_forwarding_prep_0 + 120 5 InterLabs 0x00000001057992a3 - [RKManagedObjectMappingOperationDataSource mappingOperation:targetObjectForRepresentation:withMapping:inRelationship:] + 2659 6 InterLabs 0x00000001057bfb84 - [RKMappingOperation destinationObjectForMappingRepresentation:parentRepresentation:withMapping:inRelationship:] + 1604 7 InterLabs 0x00000001057c5905 __64- [RKMappingOperation mapOneToManyRelationshipWithValue:mapping:] _ block_invoke + 117 8 CoreFoundation 0x00000001085179c4 __NSArrayEnumerate + 596 9 InterLabs 0x00000001057c5390 - [RKMappingOperation mapOneToManyRelationshipWithValue:mapping:] + 2240 10 InterLabs 0x00000001057c70d7 - [RKMappingOperation applyRelationshipMappings] + 5223 11 InterLabs 0x00000001057c8f2b - [RKMappingOperation main] + 3627 12 InterLabs 0x00000001057c80eb - [RKMappingOperation start] + 43 13 InterLabs 0x00000001057b874b - [RKMapperOperation mapRepresentation:toObject:isNew:atKeyPath:usingMapping:metadataList:] + 1723 14 InterLabs 0x00000001057b7e50 __63- [RKMapperOperation mapRepresentations:atKeyPath:usingMapping:] _ block_invoke + 336 15 CoreFoundation 0x00000001085179c4 __NSArrayEnumerate + 596 16 InterLabs 0x00000001057b7b81 - [RKMapperOperation mapRepresentations:atKeyPath:usingMapping:] + 2705 17 InterLabs 0x00000001057b9b5b - [RKMapperOperation mapRepresentationOrRepresentations:atKeyPath:usingMapping:] + 459 18 InterLabs 0x00000001057ba469 - [RKMapperOperation mapSourceRepresentationWithMappingsDictionary:] + 1945 19 InterLabs 0x00000001057badd1 - [RKMapperOperation main] + 1457 20基金会0x0000000107db5384 - [__ NSOperationInternal _start:] + 645 21 InterLabs 0x000000010580bf27 __73- [RKManagedObjectResponseMapperOperation performMappingWithObject:error:] _ block_invoke + 4743 22 CoreData 0x0000000105f9df06 developerSubmittedBlockToNSManagedObjectContextPerform + 198 23 libdispatch.dylib 0x00000001093a17f4 _dispatch_client_callout + 8 24 libdispatch.dylib 0x0000000109388774 _dispatch_barrier_sync_f_invoke + 365 25 CoreData 0x0000000105f9ddd6 - [NSManagedObjectContext performBlockAndWait:] + 230 26 InterLabs 0x000000010580a84a - [RKManagedObjectResponseMapperOperation performMappingWithObject:error:] + 1082 27 InterLabs 0x00000001058083ff - [RKResponseMapperOperation main] + 2287 28基金会0x0000000107db5384 - [__ NSOperationInternal _start:] + 645 29基金会0x0000000107db4f93 __NSOQSchedule_f + 184 30 libdispatch.dylib 0x00000001093a17f4 _dispatch_client_callout + 8 31 libdispatch.dylib 0x0000000109389b22 _dispatch_queue_drain + 1417 32 libdispatch.dylib 0x0000000109389432 _dispatch_queue_invoke + 235 33 libdispatch.dylib 0x000000010938bfc1 _dispatch_root_queue_drain + 685 34 libdispatch.dylib 0x000000010938d5d9 _dispatch_worker_thread3 + 111 35 libsystem_pthread.dylib 0x000000010970e4de _pthread_wqthread + 1129 36 libsystem_pthread.dylib 0x000000010970c341 start_wqthread + 13 ) libc ++ abi.dylib:以NSException类型的未捕获异常终止