Mantle的用法

关于mantle不多说 自行百度 以下是用法
mantle:github

//.h 文件
#import <Mantle/Mantle.h>
@interface SeytemNoticeDetail_M : MTLModel<MTLJSONSerializing>
@property (nonatomic, assign) NSInteger  groupId;
@property (nonatomic, assign) NSInteger id;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *url;
@property (nonatomic, copy) NSString *desc;
@end
@interface SeytemNotice_M : MTLModel<MTLJSONSerializing>
@property (nonatomic, assign) NSInteger  count;
@property (nonatomic, assign) NSInteger id;
@property (nonatomic, assign) NSInteger type;
@property (nonatomic, assign) BOOL isOpened;
@property (nonatomic, strong) NSArray *msgList;
@property (nonatomic, copy) NSString *msgName;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *url;
@end

@interface SeytemNotice_M_List : MTLModel<MTLJSONSerializing>
@property (nonatomic, strong) NSArray *data;
@property (nonatomic, assign) NSInteger status;
@end

markdown 为什么没有分割线 我是分割线——————————
//.m 文件

#import "SeytemNotice_M.h"
@implementation SeytemNoticeDetail_M
- (instancetype)initWithDictionary:(NSDictionary *)dictionaryValue error:(NSError **)error {
    self = [super initWithDictionary:dictionaryValue error:error];
    if (self == nil) return nil;
    // Store a value that needs to be determined locally upon initialization.
    return self;
}

+ (NSDictionary *)JSONKeyPathsByPropertyKey {
    return @{
             @"desc":@"desc",
             @"groupId":@"groupId",
             @"id":@"id",
             @"title":@"title",
             @"url":@"url",
             };
}
@end
@implementation SeytemNotice_M
+ (NSDictionary *)JSONKeyPathsByPropertyKey {
    return @{
             @"count": @"count",
             @"id": @"id",
             @"msgName": @"msgName",
             @"msgList": @"msgList",
             @"title": @"title",
             @"type": @"type",
             @"url": @"url",
             };
}
- (instancetype)initWithDictionary:(NSDictionary *)dictionaryValue error:(NSError **)error {
    self = [super initWithDictionary:dictionaryValue error:error];
    if (self == nil) return nil;
    // Store a value that needs to be determined locally upon initialization.
    return self;
}
+ (NSValueTransformer *)msgListJSONTransformer {
    return [MTLJSONAdapter arrayTransformerWithModelClass:[SeytemNoticeDetail_M class]];
}

@end

@implementation SeytemNotice_M_List
- (instancetype)initWithDictionary:(NSDictionary *)dictionaryValue error:(NSError **)error {
    self = [super initWithDictionary:dictionaryValue error:error];
    if (self == nil) return nil;

    // Store a value that needs to be determined locally upon initialization.
    return self;
}

+ (NSDictionary *)JSONKeyPathsByPropertyKey {
    return @{
             @"status":@"status",
             @"data":@"data",
             };
}
+ (NSValueTransformer *)dataJSONTransformer {
    return [MTLJSONAdapter arrayTransformerWithModelClass:[SeytemNotice_M class]];
}

@end

JSON:
api/systemMessage/groups:

{
    data =     (
                {
            count = 1;
            id = 3;
            msgList =             (
                                {
                    desc = "\U9e9f\U5eb7\U533b\U5bb6\U533b\U751f\U7aefAPP\U4f7f\U7528\U653b\U7565";
                    groupId = 3;
                    id = 13;
                    title = "\U9e9f\U5eb7\U533b\U5bb6\U533b\U751f\U7aefAPP\U4f7f\U7528\U653b\U7565";
                    url = "http://mp.weixin.qq.com/s?__biz=MjM5MjcwNTE5Ng==&mid=213674558&idx=1&sn=2f9a8d2187e78af7cf986b64aa6559d7#rd";
                }
            );
            msgName = "\U9e9f\U5eb7\U533b\U5bb6\U533b\U751f\U7aefAPP\U4f7f\U7528\U653b\U7565";
            title = "\U4f7f\U7528\U653b\U7565";
            type = 1;
            url = "http://mp.weixin.qq.com/s?__biz=MjM5MjcwNTE5Ng==&mid=213674558&idx=1&sn=2f9a8d2187e78af7cf986b64aa6559d7#rd";
        },
                {
            count = 1;
            id = 2;
            msgList =             (
                                {
                    desc = "\U7cfb\U7edf\U6d88\U606f1\U5177\U4f53\U5185\U5bb9";
                    groupId = 2;
                    id = 1;
                    title = "\U9e9f\U5eb7\U533b\U5bb6\U4ecb\U7ecd";
                    url = "http://mp.weixin.qq.com/s?__biz=MjM5MjcwNTE5Ng==&mid=201775321&idx=1&sn=175860d05ec0316b9763d8be64853363#rd";
                }
            );
            msgName = "\U9e9f\U5eb7\U533b\U5bb6\U4ecb\U7ecd";
            title = "\U516c\U53f8\U4ecb\U7ecd";
            type = 1;
            url = "http://mp.weixin.qq.com/s?__biz=MjM5MjcwNTE5Ng==&mid=201775321&idx=1&sn=175860d05ec0316b9763d8be64853363#rd";
        },
                {
            count = 11;
            id = 1;
            msgList =             (
                                {
                    desc = "\U7cfb\U7edf\U6d88\U606f2\U5185\U5bb9";
                    groupId = 1;
                    id = 2;
                    title = "\U4e0e\U6d59\U5927\U5408\U4f5c\U8bb2\U5802\U7b2c\U4e00\U671f";
                    url = "http://mp.weixin.qq.com/s?__biz=MjM5MjcwNTE5Ng==&mid=203531267&idx=4&sn=ee293a9015692fac58c9b6a52c85b070#rd";
                },
                                {
                    desc = "\U7cfb\U7edf\U6d88\U606f3\U5185\U5bb9";
                    groupId = 1;
                    id = 3;
                    title = "\U4e0e\U6d59\U5927\U5408\U4f5c\U8bb2\U5802\U7b2c\U4e8c\U671f";
                    url = "http://mp.weixin.qq.com/s?__biz=MjM5MjcwNTE5Ng==&mid=204818468&idx=1&sn=cc3022ecee7c6c7f338daf963c8852d4#rd";
                },
                                {
                    desc = "\U7cfb\U7edf\U6d88\U606f4\U5185\U5bb9";
                    groupId = 1;
                    id = 4;
                    title = "\U4e0e\U6d59\U5927\U5408\U4f5c\U8bb2\U5802\U7b2c\U4e09\U671f";
                    url = "http://mp.weixin.qq.com/s?__biz=MjM5MjcwNTE5Ng==&mid=205238258&idx=2&sn=52509a81bd000d81c1668d4884b700ca#rd";
                },
                                {
                    desc = "\U7cfb\U7edf\U6d88\U606f5\U5185\U5bb9";
                    groupId = 1;
                    id = 5;
                    title = "\U4e0e\U6d59\U5927\U5408\U4f5c\U8bb2\U5802\U7b2c\U56db\U671f";
                    url = "http://mp.weixin.qq.com/s?__biz=MjM5MjcwNTE5Ng==&mid=205672432&idx=2&sn=ad17a0790c1e8429bcbf4f637a388845#rd";
                },
                                {
                    desc = "\U7cfb\U7edf\U6d88\U606f6\U5185\U5bb9";
                    groupId = 1;
                    id = 6;
                    title = "\U4e0e\U6d59\U5927\U5408\U4f5c\U8bb2\U5802\U7b2c\U4e94\U671f";
                    url = "http://mp.weixin.qq.com/s?__biz=MjM5MjcwNTE5Ng==&mid=205913745&idx=2&sn=893f6e607bb9273c2f87104aeb954c25#rd";
                },
                                {
                    desc = "\U7cfb\U7edf\U6d88\U606f7\U5185\U5bb9";
                    groupId = 1;
                    id = 7;
                    title = "\U4e0e\U6d59\U5927\U5408\U4f5c\U8bb2\U5802\U7b2c\U516d\U671f";
                    url = "http://mp.weixin.qq.com/s?__biz=MjM5MjcwNTE5Ng==&mid=206178085&idx=2&sn=740b41b3c6133074bb15f156c7e6c28a#rd";
                },
                                {
                    desc = "\U7cfb\U7edf\U6d88\U606f8\U5185\U5bb9";
                    groupId = 1;
                    id = 8;
                    title = "\U4e0e\U6d59\U5927\U5408\U4f5c\U8bb2\U5802\U7b2c\U4e03\U671f";
                    url = "http://mp.weixin.qq.com/s?__biz=MjM5MjcwNTE5Ng==&mid=206457066&idx=2&sn=3480326902f20c6abfe56cbdd442c5fd#rd";
                },
                                {
                    desc = "\U7cfb\U7edf\U6d88\U606f9\U5185\U5bb9";
                    groupId = 1;
                    id = 9;
                    title = "\U4e0e\U6d59\U5927\U5408\U4f5c\U8bb2\U5802\U7b2c\U516b\U671f";
                    url = "http://mp.weixin.qq.com/s?__biz=MjM5MjcwNTE5Ng==&mid=206971200&idx=1&sn=e0ee51c07e6540703ab3e715dafa76d1#rd";
                },
                                {
                    desc = "\U7cfb\U7edf\U6d88\U606f10\U5185\U5bb9";
                    groupId = 1;
                    id = 10;
                    title = "\U4e0e\U6d59\U5927\U5408\U4f5c\U8bb2\U5802\U7b2c\U4e5d\U671f";
                    url = "http://mp.weixin.qq.com/s?__biz=MjM5MjcwNTE5Ng==&mid=207268723&idx=1&sn=cdf654d92cb7c71e39170c1bdfe6113c#rd";
                },
                                {
                    desc = "\U7cfb\U7edf\U6d88\U606f11\U5185\U5bb9";
                    groupId = 1;
                    id = 11;
                    title = "\U4e0e\U6d59\U5927\U5408\U4f5c\U8bb2\U5802\U7b2c\U5341\U671f";
                    url = "http://mp.weixin.qq.com/s?__biz=MjM5MjcwNTE5Ng==&mid=207268723&idx=2&sn=a8b717bfda977779a51d426b7b8f0b55#rd";
                },
                                {
                    desc = "\U7cfb\U7edf\U6d88\U606f12\U5185\U5bb9";
                    groupId = 1;
                    id = 12;
                    title = "\U4e0e\U6d59\U5927\U5408\U4f5c\U8bb2\U5802\U7b2c\U5341\U4e00\U671f";
                    url = "http://mp.weixin.qq.com/s?__biz=MjM5MjcwNTE5Ng==&mid=207518320&idx=1&sn=7795e07a2e8cdb6dd375874f70808fa2#rd";
                }
            );
            msgName = "<null>";
            title = "\U6d59\U5927\U5408\U4f5c\U8bb2\U5802";
            type = 1;
            url = "<null>";
        }
    );
    status = 0;
}

array model
dict model
model model 全都有 完毕

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值