Объект iOS Mantle Object с использованием Objective-C

Я пытаюсь разобрать следующую модель JSON с помощью библиотеки Mantle iOS для Objective-C

{
    "images": {
        "poster": {
            "url": "https://example.com"        
         }
    }
}

Вот мой код Objective-C

Model.h файл

@interface ImagesModel: MTLModel <MTLJSONSerializing>
@property(nonatomic, strong) NSString *url;
@end


@interface SuggestionModel : MTLModel <MTLJSONSerializing, SuggestionItemProtocol>

@property(nonatomic, strong) ImagesModel *poster;

@end

Model.m файл

@implementation ImagesModel
+ (NSDictionary *)JSONKeyPathsByPropertyKey {
    return @{
            @"url": @"url"
    };
}
@end

@implementation SuggestionModel

+ (NSDictionary *)JSONKeyPathsByPropertyKey {
    return @{
            @"poster": @"images.poster",
    };
}
@end

Я получаю следующую ошибку

images.poster could not resolved because an incompatible JSON dictionary was supplied: "{

Пожалуйста, помогите мне решить эту проблему. Advanced Спасибо

0 ответов

Другие вопросы по тегам