标签:
阅读目录
MJExtension是JSON和模型之间最快捷方便的转换iOS框架。
|
1
2
3
4
5
6
7
8
|
MJExtension.hMJConst.h MJConst.mMJFoundation.h MJFoundation.mMJIvar.h MJIvar.mMJType.h MJType.mNSObject+MJCoding.h NSObject+MJCoding.mNSObject+MJIvar.h NSObject+MJIvar.mNSObject+MJKeyValue.h NSObject+MJKeyValue.m |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
typedef enum { SexMale, SexFemale} Sex;@interface User : NSObject@property (copy, nonatomic) NSString *name;@property (copy, nonatomic) NSString *icon;@property (assign, nonatomic) int age;@property (assign, nonatomic) double height;@property (strong, nonatomic) NSNumber *money;@property (assign, nonatomic) Sex sex;@endNSDictionary *dict = @{ @"name" : @"Jack", @"icon" : @"lufy.png", @"age" : @20, @"height" : @"1.55", @"money" : @100.9, @"sex" : @(SexFemale) };// 将字典转为User模型User *user = [User objectWithKeyValues:dict];NSLog(@"name=%@, icon=%@, age=%d, height=%@, money=%@, sex=%d", user.name, user.icon, user.age, user.height, user.money, user.sex);// name=Jack, icon=lufy.png, age=20, height=1.550000, money=100.9, sex=1 |
项目主页:http://www.open-open.com/lib/view/home/1426233573592
JSON和模型之间最快捷方便的转换iOS框架:MJExtension
标签:
原文地址:http://www.cnblogs.com/sunnyke/p/4720794.html