Ich habe Probleme beim Zuordnen eines JSON-Arrays zu RestKit. So sieht die JSON-Datei aus:Wie man JSON-Arrays in RestKit abbildet
Ich interessiere mich für das Array "Problem". Das ist mein Mapping für eine einzelne Ausgabe:
RKObjectMapping *objectMapping = [RKObjectMapping mappingForClass:[self class] usingBlock:^(RKObjectMapping *mapping) {
[mapping mapAttributes:@"name", @"beschreibung", nil];
[mapping mapKeyPathsToAttributes:
@"id", @"identifier",
nil];
}];
Und hier ist, wie ich mein Setup ObjectMapping
RKObjectMappingProvider *omp = [RKObjectManager sharedManager].mappingProvider;
RKObjectMapping *issueMapping = [Issue mapping];
[omp addObjectMapping:issueMapping];
[omp setObjectMapping:issueMapping forKeyPath:@"issuelist.issue"];
Leider funktioniert das nicht. Ich erhalte eine Log-Ausgabe wie folgt aus:
T restkit.object_mapping:RKObjectMappingOperation.m:152 Found transformable value at keyPath 'name'. Transforming from type '__NSArrayI' to 'NSString' W restkit.object_mapping:RKObjectMappingOperation.m:232 Failed transformation of value at keyPath 'name'. No strategy for transforming from '__NSArrayI' to 'NSString' T restkit.object_mapping:RKObjectMappingOperation.m:339 Skipped mapping of attribute value from keyPath 'name to keyPath 'name' -- value is unchanged ((null)) T restkit.object_mapping:RKObjectMappingOperation.m:322 Mapping attribute value keyPath 'beschreibung' to 'beschreibung' T restkit.object_mapping:RKObjectMappingOperation.m:152 Found transformable value at keyPath 'beschreibung'. Transforming from type '__NSArrayI' to 'NSString' W restkit.object_mapping:RKObjectMappingOperation.m:232 Failed transformation of value at keyPath 'beschreibung'. No strategy for transforming from '__NSArrayI' to 'NSString' T restkit.object_mapping:RKObjectMappingOperation.m:339 Skipped mapping of attribute value from keyPath 'beschreibung to keyPath 'beschreibung' -- value is unchanged ((null)) T restkit.object_mapping:RKObjectMappingOperation.m:322 Mapping attribute value keyPath 'id' to 'identifier' T restkit.object_mapping:RKObjectMappingOperation.m:152 Found transformable value at keyPath 'id'. Transforming from type '__NSArrayI' to 'NSString' W restkit.object_mapping:RKObjectMappingOperation.m:232 Failed transformation of value at keyPath 'id'. No strategy for transforming from '__NSArrayI' to 'NSString' T restkit.object_mapping:RKObjectMappingOperation.m:339 Skipped mapping of attribute value from keyPath 'id to keyPath 'identifier' -- value is unchanged ((null)) D restkit.object_mapping:RKObjectMappingOperation.m:624 Finished mapping operation successfully...
Es scheint, als ob RestKit versucht, die ganze arry in einer Ausgabe zur Karte stattdessen eine Reihe von Fragen zu schaffen. Wie muss ich mein Mapping ändern, um dies zu korrigieren?
Danke für Ihre Hilfe!
Danke! Das war hilfreich! – thalador