我收到的 JSON 响应如下:
我正在像这样从MKCourse中的嵌套字典中设置值 -
但它总是将regionCode和regionName设为nil。我不知道出了什么问题。是否可能获取这样的值。
{
"id" : 12345
"course_name" : "history",
"teacher" : "joy",
"region" : {
"code" : "Al",
"name" : "Alabama"
}
}
我在CoreData中有一个课程实体,对应的代码模型为“MKCourse”,这个实体是这样的:
MKCourse
- id
- courseName
- teacher
- regionCode
- regionName
我正在像这样从MKCourse中的嵌套字典中设置值 -
mapping = [RKManagedObjectMapping mappingForClass:[self class] inManagedObjectStore:[[RKObjectManager sharedManager] objectStore]];
mapping.setDefaultValueForMissingAttributes = YES;
mapping.setNilForMissingRelationships = YES;
[mapping mapKeyPathsToAttributes:
@"id", [self modelIdAttribute],
@"course_name", @"courseName",
@"teacher", @"teacher",
@"region.code", @"regionCode",
@"region.name", @"regionName",
nil];
但它总是将regionCode和regionName设为nil。我不知道出了什么问题。是否可能获取这样的值。