【发布时间】:2018-04-26 10:44:42
【问题描述】:
我想为 json 创建一个模型类。 下面给出了我的 JSON 示例
来自 API 的 json 响应:
msg = '{"type":"TYPE_NM","payload":{"responseCode":0,"nextCheckTime":30}}';
我想创建一个可编码(Swift)的属性,就像在 Objective-C 中一样。
我创建了两个 nsobject 接口作为“type”和“payload”。下面我给我的课sn-ps。
//msg model
@interface MessageModel : NSObject
@property (nonatomic) NSString *type;
@property (nonatomic) Payload *payload;
@end
//for payload
@interface Payload : NSObject
@property (nonatomic) NSUInteger responseCode;
@property (nonatomic) NSUInteger nextCheckTime;
@end
【问题讨论】:
标签: objective-c json parsing model