我正在尝试将我从网络服务获得的json映射到RKEntityMapping。我在核心数据中有一个Employee对象,其中employeeId和deptId是NSNumber,name是NSString。名称正确映射,employeeId和deptId映射为0.
我的映射看起来像这样
RKEntityMapping *employeeMapping = [RKEntityMapping mappingForEntityForName:@"Employee" inManagedObjectStore:[[RKObjectManager sharedManager] managedObjectStore]];
[employeeMapping addAttributeMappingsFromDictionary:@{ @"employeeId" : @"employeeId",
@"deptId" : @"deptId",
@"name" : @"name"}];
我的json看起来像这样。
{
"employee": [
{
"employeeId": 510135,
"deptId": 123,
"name": "John"
},
{
"employeeId": 510137,
"deptId": 345,
"name": "Mike"
}
]
}
我是Restkit和Core Data的菜鸟,所以对我很轻松。谢谢:))