Ios RestKit核心数据';managedObjectStore为零';

Ios RestKit核心数据';managedObjectStore为零';,ios,core-data,restkit,restkit-0.20,Ios,Core Data,Restkit,Restkit 0.20,我不知道这是否是我问题的根本原因,但当我使用 appropriateObjectRequestOperationWithObject:nil method:RKRequestMethodGET path:path parameters:nil 它做了一些工作,当尝试映射响应时,会给我以下警告: W restkit:RKObjectManager.m:635 Asked to create an `RKManagedObjectRequestOperation` object, but mana

我不知道这是否是我问题的根本原因,但当我使用

appropriateObjectRequestOperationWithObject:nil method:RKRequestMethodGET path:path parameters:nil
它做了一些工作,当尝试映射响应时,会给我以下警告:

W restkit:RKObjectManager.m:635 Asked to create an `RKManagedObjectRequestOperation` object, but managedObjectStore is nil.
其次是:

CoreData: error: Failed to call designated initializer on NSManagedObject class 'Container'
我假设这是因为它没有将我的请求与托管对象映射相匹配,但我不知道为什么。我正在使用以下代码创建持久存储:

// Initialize managed object store
NSManagedObjectModel *managedObjectModel = [NSManagedObjectModel mergedModelFromBundles:nil];
RKManagedObjectStore *managedObjectStore = [[RKManagedObjectStore alloc] initWithManagedObjectModel:managedObjectModel];
NSError *error = nil;
[managedObjectStore createPersistentStoreCoordinator];
BOOL success = RKEnsureDirectoryExistsAtPath(RKApplicationDataDirectory(), &error);
if (! success) {
    RKLogError(@"Failed to create Application Data Directory at path '%@': %@", RKApplicationDataDirectory(), error);
}
NSString *path = [RKApplicationDataDirectory() stringByAppendingPathComponent:@"Store.sqlite"];
NSPersistentStore *persistentStore = [managedObjectStore addSQLitePersistentStoreAtPath:path fromSeedDatabaseAtPath:nil withConfiguration:nil options:nil error:&error];
if (! persistentStore) {
    RKLogError(@"Failed adding persistent store at path '%@': %@", path, error);
}
[managedObjectStore createManagedObjectContexts];
适当的映射/响应描述符:

RKEntityMapping *containerMapping = [RKEntityMapping mappingForEntityForName:@"Container" inManagedObjectStore:managedObjectStore];
[containerMapping addAttributeMappingsFromDictionary:@{
                                                  @"id" : @"containerId",
                                                  @"name" : @"name",
                                                  @"public" : @"isPublic",
                                                  @"user": @"userId",
                                                  }];
containerMapping.identificationAttributes = @[@"containerId"];

responseDescriptor = [RKResponseDescriptor 
    responseDescriptorWithMapping:containerMapping
    method:RKRequestMethodAny
    pathPattern:nil 
    keyPath:@"containers"
    statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];

您似乎没有使用对托管对象存储的引用配置对象管理器。创建对象管理器时应执行此操作:

objectManager.managedObjectStore = managedObjectStore;
如果没有这个RestKit,就只能对所有内容使用普通对象操作


注意:如果您正在记录警告,您将看到
要求您创建RKSManagedObjectRequestOperation对象,但managedObjectStore在日志输出中为nil

您似乎没有使用对托管对象存储的引用配置对象管理器。创建对象管理器时应执行此操作:

objectManager.managedObjectStore = managedObjectStore;
如果没有这个RestKit,就只能对所有内容使用普通对象操作


注意:如果您正在记录警告,您将看到
要求您创建RKManagedObjectRequestOperation对象,但managedObjectStore在日志输出中为nil

您的响应描述符应设置路径模式。您从
适当的ObjectRequestOperationWithObject
中得到了什么类类型?我附带加载了很多项,因此它可能来自许多不同的路径(例如,从/containers,或者由于附带加载了容器列表而从/users)。您是否加载了响应描述符无效的路径?您是否向对象管理器提供了对托管对象存储的引用?“您是否向对象管理器提供了对托管对象存储的引用?”-这也是我的第一个想法,因为我找到的示例中没有一个说明如何做到这一点。我想知道它怎么知道对象存储在哪里。我该怎么做?(facepalm)-objectManager.managedObjectStore=managedObjectStore;您的响应描述符应该有一个路径模式集。您从
适当的ObjectRequestOperationWithObject
中得到了什么类类型?我附带加载了很多项,因此它可能来自许多不同的路径(例如,从/containers,或者由于附带加载了容器列表而从/users)。您是否加载了响应描述符无效的路径?您是否向对象管理器提供了对托管对象存储的引用?“您是否向对象管理器提供了对托管对象存储的引用?”-这也是我的第一个想法,因为我找到的示例中没有一个说明如何做到这一点。我想知道它怎么知道对象存储在哪里。我该怎么做?(facepalm)-objectManager.managedObjectStore=managedObjectStore;