delegate

导航

 
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);

 

posted on 2015-04-29 17:43  jsonUserList  阅读(316)  评论(0编辑  收藏  举报