Domanda

come dovrebbe apparire la mappatura se ho una risposta JSON come questa:

{
"persons":{
  "@size":"4",
  "person":[
     {
        "name":"John",
        "type":"Doe 1",
        "options":"some options"
     },
     {
        "name":"John",
        "type":"Doe 2",
        "options":"some other options"
     },
     {
        "name":"John",
        "type":"Doe 3",
     },
     {
        "name":"John",
        "type":"Doe 4",
     }
  ]
 }
 }

Ho già provato la seguente mappatura, ma non funziona:

RKManagedObjectMapping* personMapping = [RKManagedObjectMapping mappingForClass:[CDCustomFieldDefinition class]];
[personMapping mapKeyPath:@"label" toAttribute:@"label"];
[personMapping mapKeyPath:@"type" toAttribute:@"type"];
[personMapping mapKeyPath:@"options" toAttribute:@"options"];
personMapping.primaryKeyAttribute = @"label";

[[RKObjectManager sharedManager].mappingProvider setMapping:personMapping forKeyPath:@"persons"];

Il mio array di oggetti in didLoadObjects: è sempre vuoto ... qualche idea?Grazie mille!

È stato utile?

Soluzione

Should the keypath be

@"persons.person"
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top