Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/98.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何使用';地幔';_Ios_Objective C_Json - Fatal编程技术网

Ios 如何使用';地幔';

Ios 如何使用';地幔';,ios,objective-c,json,Ios,Objective C,Json,这是我的模型: @interface ZpCouncilVClrAppListModel : MTLModel <MTLJSONSerializing> @property (nonatomic , assign) long long theId ; // 应用编号 @property (nonatomic , assign) NSUInteger index ; // 应用名称 @property (nonatomic , strong) NSString *name ; // 顺

这是我的模型:

@interface ZpCouncilVClrAppListModel : MTLModel <MTLJSONSerializing>
@property (nonatomic , assign) long long theId ; // 应用编号
@property (nonatomic , assign) NSUInteger index ; // 应用名称
@property (nonatomic , strong) NSString *name ; // 顺序号
@property (nonatomic , assign) NSInteger version ; // 最新版本号
@end

@interface ZpCouncilVClrCenterAdvModel : MTLModel <MTLJSONSerializing>
@property (nonatomic , strong) NSString *title ; // 标题
@property (nonatomic , strong) NSString *imageUrl ; // 图片URL
@property (nonatomic , strong) NSString *toUrl ; // 链接地址URL
@end

@interface ZpCouncilVClrNewsListModel : MTLModel <MTLJSONSerializing>
@property (nonatomic , strong) NSString *title ; // 标题
@property (nonatomic , strong) NSString *imageUrl ; // 图片
@property (nonatomic , assign) NSTimeInterval createDate ; // 时间
@end

@interface ZpCouncilVClrTopAdvModel : MTLModel <MTLJSONSerializing>
@property (nonatomic , strong) NSString *title ; // 标题
@property (nonatomic , strong) NSString *imageUrl ; // 图片URL
@property (nonatomic , strong) NSString *toUrl ; // 链接地址URL
@end

@interface ZpCouncilVClrModel : MTLModel <MTLJSONSerializing>
@property (nonatomic , strong) NSArray<ZpCouncilVClrAppListModel *>* appList ;
@property (nonatomic , strong) NSArray<ZpCouncilVClrCenterAdvModel *>* centerAdv ;
@property (nonatomic , strong) NSArray<ZpCouncilVClrNewsListModel *>* newsList ;
@property (nonatomic , strong) NSArray<ZpCouncilVClrTopAdvModel *>* topAdv ;
+ (ZpCouncilVClrModel *)createModelWith:(NSDictionary *)jsonParams ;
@end
您可以看到一个方法:

[ + (ZpCouncilVClrModel *)createModelWith:(NSDictionary *)jsonParams ]
在该方法中,我使用MTLJSONAdapter类将json字典转换为ZPCouncillVCLRModel*对象。
你可以看到代码

ZpCouncilVClrModel *jsonModel = [MTLJSONAdapter modelOfClass:[self class] fromJSONDictionary:jsonParams error:&error];
但是

我检查了结果,发现对象(名称为jsonModel)存在,但jsonModel的属性为nil


你能帮我一下吗,为什么jsonModel的属性是nil?提前感谢。

由于类的命名,您的代码很难阅读。[MTLJSONAdapter modelOfClass:]返回nil,因此您必须找出其中的错误。您将它作为error参数传递&error,您是否已经在该方法调用后检查了error的值?您是否已将传递到
modelOfClass:…
方法的NSDictionary记录下来?
ZpCouncilVClrModel *jsonModel = [MTLJSONAdapter modelOfClass:[self class] fromJSONDictionary:jsonParams error:&error];