Mantle / Mantle

Model framework for Cocoa and Cocoa Touch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parsing array with objects of different subclasses

shmueldw opened this issue · comments

Hi.

I need to parse JSON array like this:
[
{
"time": "1",
"type" : "a",
"custom_field_a": "avalue"
},
{
"time": "2",
"type" : "b",
"custom_field_b": "bvalue"
}
]

@interface BaseClass : MTLModel

@Property (nonatomic, readonly) NSString time;
@Property (nonatomic, readonly) NSString type;

@EnD

@interface ClassA : BaseClass

@Property (nonatomic, readonly) NSString customFieldA;

@EnD

@interface ClassB : BaseClass

@Property (nonatomic, readonly) NSString customFieldB;

@EnD

So I am not sure how can I parse. Could you help me?