I am attempting to map my Core Data "Component" Entity to the "hotspots" keypath in this response JSON, but it only gets to the array object so it will not map. I can't tell if my problem is the mapping or the response descriptor or a combination of the two.
"result" : {
"type" : "Slidedeck",
"id" : 81,
"name" : "Brendantest",
"slides" : [
{
"thumb" : "http:\/\/api.idetailapp.review.thingee.com\/v4\/resources\/1294\/download\/slide?thumb=true",
"id" : 1294,
"notes" : "",
"label" : "",
"order" : 1,
"parent_id" : 81,
"file" : "slide-20.jpg",
"components" : {
"hotspots" : [
{
"x" : 205,
"options" : "embedded",
"type" : "video",
"id" : 6082,
"y" : 453,
"assets" : [
{
"thumb" : "\/system\/asset_objects\/14\/original_thumb\/14.png",
"id" : 14,
"parent_id" : 6082,
"file" : "slide_15_chart_animation_ipad_r03.mov",
"url" : "http:\/\/api.idetailapp.review.thingee.com\/v4\/resources\/14\/download\/asset"
}
],
"parent_id" : 1294,
"width" : 320,
"height" : 246
}
]
},
"url" : "http:\/\/api.idetailapp.review.thingee.com\/v4\/resources\/1294\/download\/slide"
}
],
"version" : "0.43"
} }
Here is my RKEntityMapping:
RKEntityMapping *mapping = [RKEntityMapping mappingForEntityForName:@"Component"
inManagedObjectStore:[RKManagedObjectStore defaultStore]];
mapping.identificationAttributes = @[ @"componentID" ];
[mapping addAttributeMappingsFromDictionary:@{@"id": @"componentID",
@"parent_id": @"parentID"
}];
[mapping addAttributeMappingsFromArray:@[@"x", @"y", @"width", @"height", @"type", @"options"]];
Here is my Responsedescriptor:
componentResponseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:componentEntityMapping
method:RKRequestMethodAny pathPattern:nil
keyPath:@"result.slides.components.hotspots" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];
I put in a RestKit/ObjectMapping debug trace and get to the following output:
Asked to map source object (
{
assets = (
{
file = "slide_15_chart_animation_ipad_r03.mov";
id = 14;
"parent_id" = 6082;
thumb = "/system/asset_objects/14/original_thumb/14.png";
url = "http://api.idetailapp.review.thingee.com/v4/resources/14/download/asset";
}
);
height = 246;
id = 6082;
options = embedded;
"parent_id" = 1294;
type = video;
width = 320;
x = 205;
y = 453;
}
And further debug message of:
Failed transformation of value at keyPath 'id' to representation of type 'NSNumber': Error Domain=org.restkit.RKValueTransformers.ErrorDomain Code=3002 "Failed transformation of value '(
6082
)UserInfo=0x12479350 {NSLocalizedDescription=Expected an inputValue of type NSNull, but got a __NSArrayI.}"
),
slidesonly ever have 1 element? (your mapping got further than I expected...)