RESTKIT解析CoreData关系错误如何解决?
How to Rectify the Relationship Fault in CoreData While parsing RESTKIT?
我想将 EY_ConnectionUsage
实体值存储到 EY_Connection
实体 Cell.I 已经添加了两个具有属性的实体并创建了名称为 usageData
的关系。但这显示错误“<'usageData' Relationship Fault>”。这是我编写的将 RESTKIT 值映射到 CoreData 的方法。
DataAccessHandler.m
+(void)createConnectionMappingWithStore:(RKManagedObjectStore *)managedObjectStore saveInDelegate:(AppDelegate *)appDelegate{
NSLog(@"appdele==>>%@",appDelegate);
RKEntityMapping *connectionMapping = [RKEntityMapping mappingForEntityForName:@"EY_Connections" inManagedObjectStore:managedObjectStore];
connectionMapping.identificationAttributes = @[@"connectionNumber"];
[connectionMapping addAttributeMappingsFromDictionary:@{ @"ServiceNo" : @"connectionServiceNumber", @"Name" : @"connectionName", @"Region" : @"connectionRegion", @"Phase" : @"connectionPhase",
@"Circle" : @"connectionCircle", @"Section" : @"connectionSection", @"Load" : @"connectionLoad",
@"Distribution" : @"connectionDistribution", @"MeterNo" : @"connectionMeterNumber", @"ConnectionNumber" : @"connectionNumber", @"Address" : @"connectionAddress", @"ServiceStatus" : @"connectionStatus"}];
RKEntityMapping *connectionUsageMapping = [RKEntityMapping mappingForEntityForName:@"EY_ConnectionUsage" inManagedObjectStore:managedObjectStore];
connectionUsageMapping.identificationAttributes = @[@"usageAssessmentDate"];
[connectionUsageMapping addAttributeMappingsFromDictionary:@{ @"assessment_date" : @"usageAssessmentDate", @"reading" : @"usageReading", @"units" : @"usageUnits", @"amount" : @"usageAmount",
@"payment_date" : @"usagePaymentDate", @"status" : @"usageStatus"}];
[connectionMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"usage" toKeyPath:@"usageData" withMapping:connectionUsageMapping]];
RKResponseDescriptor *articleListResponseDescriptor =
[RKResponseDescriptor responseDescriptorWithMapping:connectionMapping
method:RKRequestMethodGET
pathPattern:@"user_history/consumer/data.json"
keyPath:nil
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)
];
[appDelegate createObjectManagerForurl:@"http://sciflare.com/energyly/api/" andAddResponseDescriptor:articleListResponseDescriptor];
[AFNetworkActivityIndicatorManager sharedManager].enabled = YES;
}
<'usageData' Relationship Fault>
这意味着尚未加载关系数据,因为您还没有尝试使用它。记录对象不足以加载数据。故障系统的全部意义在于防止同时将太多数据加载到内存中。
所以,基本上,它不是一个故障的问题。当您尝试使用它时,数据将被填充,一切都会好起来的。
CoreData 说 'load only needed data'。如果我们试图获取不需要的数据,那么 coredata 会显示 'FAULT'.
敌人更详细请看CoreData Fault
我想将 EY_ConnectionUsage
实体值存储到 EY_Connection
实体 Cell.I 已经添加了两个具有属性的实体并创建了名称为 usageData
的关系。但这显示错误“<'usageData' Relationship Fault>”。这是我编写的将 RESTKIT 值映射到 CoreData 的方法。
DataAccessHandler.m
+(void)createConnectionMappingWithStore:(RKManagedObjectStore *)managedObjectStore saveInDelegate:(AppDelegate *)appDelegate{
NSLog(@"appdele==>>%@",appDelegate);
RKEntityMapping *connectionMapping = [RKEntityMapping mappingForEntityForName:@"EY_Connections" inManagedObjectStore:managedObjectStore];
connectionMapping.identificationAttributes = @[@"connectionNumber"];
[connectionMapping addAttributeMappingsFromDictionary:@{ @"ServiceNo" : @"connectionServiceNumber", @"Name" : @"connectionName", @"Region" : @"connectionRegion", @"Phase" : @"connectionPhase",
@"Circle" : @"connectionCircle", @"Section" : @"connectionSection", @"Load" : @"connectionLoad",
@"Distribution" : @"connectionDistribution", @"MeterNo" : @"connectionMeterNumber", @"ConnectionNumber" : @"connectionNumber", @"Address" : @"connectionAddress", @"ServiceStatus" : @"connectionStatus"}];
RKEntityMapping *connectionUsageMapping = [RKEntityMapping mappingForEntityForName:@"EY_ConnectionUsage" inManagedObjectStore:managedObjectStore];
connectionUsageMapping.identificationAttributes = @[@"usageAssessmentDate"];
[connectionUsageMapping addAttributeMappingsFromDictionary:@{ @"assessment_date" : @"usageAssessmentDate", @"reading" : @"usageReading", @"units" : @"usageUnits", @"amount" : @"usageAmount",
@"payment_date" : @"usagePaymentDate", @"status" : @"usageStatus"}];
[connectionMapping addPropertyMapping:[RKRelationshipMapping relationshipMappingFromKeyPath:@"usage" toKeyPath:@"usageData" withMapping:connectionUsageMapping]];
RKResponseDescriptor *articleListResponseDescriptor =
[RKResponseDescriptor responseDescriptorWithMapping:connectionMapping
method:RKRequestMethodGET
pathPattern:@"user_history/consumer/data.json"
keyPath:nil
statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)
];
[appDelegate createObjectManagerForurl:@"http://sciflare.com/energyly/api/" andAddResponseDescriptor:articleListResponseDescriptor];
[AFNetworkActivityIndicatorManager sharedManager].enabled = YES;
}
<'usageData' Relationship Fault>
这意味着尚未加载关系数据,因为您还没有尝试使用它。记录对象不足以加载数据。故障系统的全部意义在于防止同时将太多数据加载到内存中。
所以,基本上,它不是一个故障的问题。当您尝试使用它时,数据将被填充,一切都会好起来的。
CoreData 说 'load only needed data'。如果我们试图获取不需要的数据,那么 coredata 会显示 'FAULT'.
敌人更详细请看CoreData Fault