Search code examples
iosjsonmodel

What's wrong with JsonModel for iOS


This has been working for me before, but suddenly it has stopped working.

I had an object Coupon parsed well by JSONModel, and indeed the object is not null, but when I cast some of the properties, for example coupon.title I get this error.

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary title]: unrecognized selector sent to instance 0x7f8510645ba0'

Why is this happening? Thank you.

This is my object:

#import "JSONModel.h"

@protocol Coupon
@end

@interface Coupon : JSONModel;
@property (assign, nonatomic) NSString* title;
@property (strong, nonatomic) NSString* subtitle;
@property (strong, nonatomic) NSString* text;
@end

and the json:

{
"subtitle":"ENDOR",
"title":"This IS THE OBJECT 1",
"text":"And this is the text of the coupon!!!"
}

Solution

  • Well, the problem was residing in a Pod that I've installed, in particular this bug.