首页 > Web开发 > 详细

JSONModel

时间:2015-04-29 19:24:51      阅读:255      评论:0      收藏:0      [点我收藏+]
1 //仅仅声明属性的类,称为实体类(模型类)
2 //Student.h中声明属性
3 @property(strong,nonatomic)NSString *name;
4 @property(assign,nonatomic)int age;
5 @property(strong,nonatomic)NSArray *array;
//导入JSONModel第三方库
//在AppDelegate.h中引入学生类的头文件
//在AppDelegate.m要写的代码
//JsonModel作用为将数据转换成模型
NSString *str=@"{\"name\":\"zhangsan\",\"age\":20,\"array\":[\"a\"]}";
//用数据初始化对象
Student *stu=[[Student alloc]initWithString:str error:nil];
NSLog(@"%@",stu);
NSLog(@"%@",stu.toDictionary);
NSLog(@"%@",stu.toJSONString);

 

JSONModel

原文:http://www.cnblogs.com/y16879w/p/4466630.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!