I have a question about displaying a nested array. At https://github.com/RestKit/RestKit/blob/master/Docs/Object%20Mapping.md there is an example for matching nested objects.
But what should I do if the nested object is an array of objects, for example JSON looks like this:
{ "articles": [ { "title": "RestKit Object Mapping Intro", "body": "This article details how to use RestKit object mapping...", "author": [{ "name": "Blake Watters", "email": " blake@restkit.org " }, { "name": "abc", "email": "emailaddress" }] "publication_date": "7/4/2011" }] }
What should my classes look like to get an array of authors? This is the code from the example:
@interface Author : NSObject @property (nonatomic, retain) NSString* name; @property (nonatomic, retain) NSString* email; @end @interface Article : NSObject @property (nonatomic, retain) NSString* title; @property (nonatomic, retain) NSString* body; @property (nonatomic, retain) Author* author; // should be an array of Author-Objects @property (nonatomic, retain) NSDate* publicationDate; @end
How can I tell Restkit that theres Array of Authors and if I change the author attribute class in an NSArray article, how does Restkit know that there must be Author-Objects in this NSArray ... ??
I use RKObjectMapping to map objects from JSON to Objective-c and vice versa.
source share