1
我造型没有问题的正常JSON对象,但现在国际化我想下面的场景,其中一个属性可以是一个字符串或键/值对的字典型号:如何将不同的JSON输入映射到RestKit中的同一对象?
"objects": [{"title": "non internatinalizaed title", ...},
{"title": {"en": "english string", "es": "spanish string"}, ...},
....]
因为我不知道如果服务器会发送一个字符串或多个字符串我想创建这样一个模型对象:
@interface I18NString : Object
@property (copy) NSString *forced; // Set when there is no i18n
@property (copy) NSDictionary *strings; // Set with i18n.
- (NSString*)stringValue; // Returns forced or one of strings
取决于strings
是不是nil我会选择一个类似C结构的结合,财产或其他在stringValue
方法。我已阅读restkit wiki中的Dynamic object mapping部分,但我无法看到如何使用它来解决此问题。