我想将EY_ConnectionUsage
实体值存储到EY_Connection
实体Cell.I已添加两个具有属性和创建关系的实体,名称为usageData
。但这显示错误&#34 ;<' usageData'关系错误>"。这是我编写的将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;
}
答案 0 :(得分:1)
<' usageData'关系错误>
这意味着关系数据尚未加载,因为您还没有尝试过使用它。记录对象不足以加载数据。故障系统的重点是防止过多的数据同时加载到内存中。
所以,基本上,这不是一个问题,而是一个错误。当您尝试使用它时,将填充数据并且一切都会正常。
答案 1 :(得分:0)
CoreData表示“仅加载所需的数据”#。如果我们尝试获取不需要的数据,则coredata会显示“FAULT'。
”更多细节请通过CoreData Fault