JSONModel 简单例子
// ProductModel.h
// JSONModel
//
// Created by 张国锋 on 15/7/20.
// Copyright (c) 2015年 张国锋. All rights reserved.
// #import "JSONModel.h" @interface ProductModel : JSONModel @property (nonatomic,strong)NSString<Optional> * id1;
@property (nonatomic,strong)NSString<Optional> * name;
@property (nonatomic,strong)NSString<Optional> * price; @end // ProductModel.m
// JSONModel
//
// Created by 张国锋 on 15/7/20.
// Copyright (c) 2015年 张国锋. All rights reserved.
// #import "ProductModel.h" @implementation ProductModel
+(JSONKeyMapper *)keyMapper{
return [[JSONKeyMapper alloc] initWithDictionary:@{@"id":@"id1",@"sss":@"xxxxx"}];
}
@end
// test1Model.h
// JSONModel
//
// Created by 张国锋 on 15/7/20.
// Copyright (c) 2015年 张国锋. All rights reserved.
// #import "JSONModel.h" @protocol test2Model
@end @interface test2Model : JSONModel
@property (nonatomic,strong)NSString<Optional> * id1;
@property (nonatomic,strong)NSString<Optional> * name;
@property (nonatomic,strong)NSString<Optional> * price;
@end @interface test1Model : JSONModel
@property (nonatomic,strong)NSString<Optional> * order_id;
@property (nonatomic,strong)NSString<Optional> * total_price;
@property (nonatomic,strong)NSArray<test2Model,Optional> * product;
@end // test1Model.m
// JSONModel
//
// Created by 张国锋 on 15/7/20.
// Copyright (c) 2015年 张国锋. All rights reserved.
// #import "test1Model.h" @implementation test2Model +(JSONKeyMapper *)keyMapper{
return [[JSONKeyMapper alloc] initWithDictionary:@{@"id":@"id1"}];
} @end @implementation test1Model @end
// ViewController.h
// JSONModel
//
// Created by 张国锋 on 15/7/20.
// Copyright (c) 2015年 张国锋. All rights reserved.
// #import <UIKit/UIKit.h> @interface ViewController : UIViewController @end //
// ViewController.m
// JSONModel
//
// Created by 张国锋 on 15/7/20.
// Copyright (c) 2015年 张国锋. All rights reserved.
// #import "ViewController.h"
#import "test1Model.h"
@interface ViewController () @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
NSDictionary *dic=[[NSDictionary alloc]init];
test1Model *model=[[test1Model alloc]initWithDictionary:dic error:nil];
/*
@property (nonatomic,strong)NSString<Optional> * order_id;
@property (nonatomic,strong)NSString<Optional> * total_price;
@property (nonatomic,strong)NSArray<test2Model,Optional> * product;
*/
// Do any additional setup after loading the view, typically from a nib.
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
JSONModel 简单例子的更多相关文章
- Hibernate4.2.4入门(一)——环境搭建和简单例子
一.前言 发下牢骚,这段时间要做项目,又要学框架,搞得都没时间写笔记,但是觉得这知识学过还是要记录下.进入主题了 1.1.Hibernate简介 什么是Hibernate?Hibernate有什么用? ...
- AgileEAS.NET SOA 中间件平台.Net Socket通信框架-简单例子-实现简单的服务端客户端消息应答
一.AgileEAS.NET SOA中间件Socket/Tcp框架介绍 在文章AgileEAS.NET SOA 中间件平台Socket/Tcp通信框架介绍一文之中我们对AgileEAS.NET SOA ...
- spring mvc(注解)上传文件的简单例子
spring mvc(注解)上传文件的简单例子,这有几个需要注意的地方1.form的enctype=”multipart/form-data” 这个是上传文件必须的2.applicationConte ...
- ko 简单例子
Knockout是在下面三个核心功能是建立起来的: 监控属性(Observables)和依赖跟踪(Dependency tracking) 声明式绑定(Declarative bindings) 模板 ...
- mysql定时任务简单例子
mysql定时任务简单例子 ? 1 2 3 4 5 6 7 8 9 如果要每30秒执行以下语句: [sql] update userinfo set endtime = now() WHE ...
- java socket编程开发简单例子 与 nio非阻塞通道
基本socket编程 1.以下只是简单例子,没有用多线程处理,只能一发一收(由于scan.nextLine()线程会进入等待状态),使用时可以根据具体项目功能进行优化处理 2.以下代码使用了1.8新特 ...
- 一个简单例子:贫血模型or领域模型
转:一个简单例子:贫血模型or领域模型 贫血模型 我们首先用贫血模型来实现.所谓贫血模型就是模型对象之间存在完整的关联(可能存在多余的关联),但是对象除了get和set方外外几乎就没有其它的方法,整个 ...
- [转] 3个学习Socket编程的简单例子:TCP Server/Client, Select
以前都是采用ACE的编写网络应用,最近由于工作需要,需要直接只用socket接口编写CS的代码,重新学习这方面的知识,给出自己所用到的3个简单例子,都是拷贝别人的程序.如果你能完全理解这3个例子,估计 ...
- jsonp的简单例子
jsonp的简单例子 index.html <!DOCTYPE html> <html> <head> <meta charset="UTF-8&q ...
随机推荐
- ACM学习历程——HDU1331 Function Run Fun(锻炼多维dp的打表)
Description We all love recursion! Don't we? Consider a three-parameter recursive function w( ...
- 【LeetCode】011 Container With Most Water
题目: Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, a ...
- python+selenium自动化测试环境搭建
selenium 是一个web的自动化测试工具,不少学习功能自动化的同学开始首选selenium ,相因为它相比QTP有诸多有点: * 免费,也不用再为破解QTP而大伤脑筋 * 小巧,对于不同的语 ...
- AtCoder Regular Contest 073 E:Ball Coloring
题目传送门:https://arc073.contest.atcoder.jp/tasks/arc073_c 题目翻译 给你\(N\)个袋子,每个袋子里有俩白球,白球上写了数字.对于每一个袋子,你需要 ...
- POJ1502(最短路入门题)
MPI Maelstrom Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 7471 Accepted: 4550 Des ...
- CodeForces 1091H. New Year and the Tricolore Recreation
题目简述:给定$n \leq 10^5$个三元组$(b_i, w_i, r_i)$,其中$10^5 \leq b_i < w_i < r_i \leq 10^5$,以及一个限制参数$f$. ...
- 编译portmap和nfs-utils
编译portmap和nfs-utils 为了在播放机上实现NFS服务器的功能,我们已经在uClibc中打开了完整RPC支持,并且在新编译的内核中打开了NFS服务器支持.此外还有两个软件包也是提供NFS ...
- go实现冒泡排序和快速排序
项目结构 冒泡排序算法,源文件bubblesort.go package bubblesort // 冒泡排序 func BubbleSort(values []int) { for i := 0; ...
- Guid.NewGuid().ToString()的几种格式 (转)
1.Guid.NewGuid().ToString("N") 结果为: 38bddf48f43c48588e0d78761eaa1ce6 2.Guid.NewGuid() ...
- uva11584 Partitioning by Palindromes
题目大意: 给出一个字符串,把他划分成尽量少的回文串,问最少的回文串个数 /* 先预处理所有回文子串 dp[i]表示字符1~i划分成的最小回文串的个数 */ #include<iostream& ...