0

There are two JSONModels-Question and Option. Question model has following property.

@property NSArray<Option *> *optionsArray;

and keyMapper

+ (JSONKeyMapper *)keyMapper {
      return [[JSONKeyMapper alloc] initWithDictionary:@{
                                                       @"options": @"optionsArray",
                                                       }];
}

And Option model has following keyMapper

+ (JSONKeyMapper *)keyMapper {    
    return [[JSONKeyMapper alloc] initWithDictionary:@{
                                                       @"option_id":@"optionID",                                                           @"value":@"optionValuesDictionary"
                                                       }];
}

The question is

[[Question alloc] initWithDictionary:questionDictionary error:&parseError];

is returning a question object with optionArray(There are elements in the array, not empty). But each element in that array is an NSDictionary. Not Option model with proper keymapping. Why is it like that?

Darth Pingu
  • 101
  • 2

1 Answers1

0

I think the proper way to declare the property is creating a protocol for the desired object that represents the elements of the array.

@protocol Option
@end

Then, on the property you declared:

@property NSArray<Option> *optionsArray;
Alan Raso
  • 1
  • 1
  • 1