JSONModel 多级
来源:互联网 发布:自己做淘宝需要哪些条件 编辑:程序博客网 时间:2024/04/28 13:52
模型里面套模型
#import <JSONModelD/JSONModel.h>
#import "ExamListModel.h"
//@protocol ExamListModel
//@end
//
//@interface ExamListModel : JSONModel
//@property (assign, nonatomic) int id;
//@property (strong, nonatomic) NSString* name;
//@property (assign, nonatomic) float price;
//@end
//
//@implementation ExamListModel
//@end
@interface ExamModel : JSONModel
@property (nonatomic, strong)NSString *id;
@property (nonatomic, strong)NSString *name;
@property (nonatomic, assign)NSInteger questionType;
@property (nonatomic, strong)NSString *score;
@property (nonatomic, strong)NSString *answer;
@property (nonatomic, strong)NSString *orderNum;
@property (nonatomic, strong) NSMutableArray *oldListData;
@property (nonatomic, strong)NSMutableArray <ExamListModel*>* qOptions;
@end
其中后台返回套的模型数组的名字为qOptions
#import "ExamModel.h"
@implementation ExamModel
+ (BOOL)propertyIsOptional:(NSString *)propertyName {
return YES;
}
- (NSMutableArray *)qOptions{
if (!_qOptions) {
_qOptions = [NSMutableArray array];
}
return _qOptions;
}
+ (NSString *)protocolForArrayProperty:(NSString *)propertyName
{
if ([propertyName isEqualToString:@"qOptions"]) {
return NSStringFromClass([ExamListModel class]);
} else {
return nil;
}
}
#import <JSONModelD/JSONModel.h>
//"id": 61463,
//"name": "临沂",
//"optionName": "B",
//"question": 381226,
//"orderNum": 2
@interface ExamListModel : JSONModel
@property (nonatomic, copy) NSString *id;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *optionName;
@property (nonatomic, copy) NSString *question;
@property (nonatomic, copy) NSString *orderNum;
@end
#import "ExamListModel.h"
@implementation ExamListModel
+ (BOOL)propertyIsOptional:(NSString *)propertyName {
return YES;
}
@end
- JSONModel 多级
- jsonModel
- JSONModel
- JSONModel
- JSONModel
- JSONModel
- 使用 JSONModel
- JSONModel & MJExtension
- JSONModel使用
- JsonModel使用
- JSONModel, Mantle
- JSONModel使用
- JSONModel 使用
- JSONModel使用
- JSONModel源码阅读笔记
- JSONModel源码阅读笔记
- JSONModel的使用
- JsonModel的使用
- 一起来编写汇编语言
- Spring Boot——开发新一代Spring Java应用
- 记3.9——Apple禁止热更新而受影响的第三方SDK
- NTC33 African Wildlife Theme Wild Gambler in iBET
- String类型
- JSONModel 多级
- 模仿小米时钟
- linux下某个文件中文乱码
- docker 常用命令大全
- Mac 版本下IDEA简单知识
- Python提取保存 Win10系统 锁屏壁纸 桌面图片
- 菜鸟用scrapy爬取虎扑图片
- 谷歌浏览器怎么调试js
- linux 按键驱动代码分析