Array displaying RestKit strings and KeyPath value for one object

I have been looking for an answer in a few hours, I have no idea what to do.

I have a JSON that I need to map, which has an array of strings without keyPath, but also has an attribute to display, which has keyPath. I used RestKit 0.21.0 and had the same error when upgrading to RestKit 0.22.0.

JSON:

{
  "content": {
    "site": "www.inf.ufsc.br/~fcdocil",
    "modulos": [
      "noticias",
      "fotos",
      "conteudo"
    ]
  }
}

RKResponseDescriptor:

RKEntityMapping *moduleMapping = [RKEntityMapping mappingForEntityForName:@"Module" inManagedObjectStore:store];
    [moduleMapping addPropertyMapping:[RKAttributeMapping attributeMappingFromKeyPath:nil toKeyPath:@"type"]];
    [moduleMapping addAttributeMappingsFromDictionary:@{@"@parent.site" : @"site"}];

    RKResponseDescriptor *responseDescriptor = [RKResponseDescriptor responseDescriptorWithMapping:moduleMapping method:RKRequestMethodAny pathPattern:nil keyPath:@"content.modulos" statusCodes:RKStatusCodeIndexSetForClass(RKStatusCodeClassSuccessful)];

When I run this, it successfully maps the array to 3 different elements, as you can see here:

SUCCESS (
    "<Module: 0x8e54280> (entity: Module; id: 0x8cd31f0 <x-coredata://B31664A2-091E-43B8-9B36-EB7AF6C27292/Module/p4> ; data: {\n    site = nil;\n    type = noticias;\n})",
    "<Module: 0x8e666b0> (entity: Module; id: 0x8cd3180 <x-coredata://B31664A2-091E-43B8-9B36-EB7AF6C27292/Module/p2> ; data: {\n    site = nil;\n    type = fotos;\n})",
    "<Module: 0x8e66a60> (entity: Module; id: 0x8cd3170 <x-coredata://B31664A2-091E-43B8-9B36-EB7AF6C27292/Module/p3> ; data: {\n    site = nil;\n    type = conteudo;\n})"
)

But he did not @parent.site, which I wish:

SUCCESS (
    "<Module: 0x8e54280> (entity: Module; id: 0x8cd31f0 <x-coredata://B31664A2-091E-43B8-9B36-EB7AF6C27292/Module/p4> ; data: {\n    site = www.inf.ufsc.br/~fcdocil;\n    type = noticias;\n})",
    "<Module: 0x8e666b0> (entity: Module; id: 0x8cd3180 <x-coredata://B31664A2-091E-43B8-9B36-EB7AF6C27292/Module/p2> ; data: {\n    site = www.inf.ufsc.br/~fcdocil;\n    type = fotos;\n})",
    "<Module: 0x8e66a60> (entity: Module; id: 0x8cd3170 <x-coredata://B31664A2-091E-43B8-9B36-EB7AF6C27292/Module/p3> ; data: {\n    site = www.inf.ufsc.br/~fcdocil;\n    type = conteudo;\n})"
)

I use CoreData to save data, and my ManagedObject is like this,

module.h

@interface Module : NSManagedObject

@property (nonatomic, retain) NSString * type;
@property (nonatomic, retain) NSString * site;

@end

Module.m

@implementation Module

@dynamic type;
@dynamic site;

@end

I really have no idea what I'm doing wrong, so any suggestions would be appreciated. Thanks

+4
1

@"content.modulos", RestKit JSON ( ). @parent .

. RestKit , site , modulos ( , RKRelationshipMapping), . , @parent, . site @"content".

+1

All Articles