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 ...
随机推荐
- 杂文笔记《“去QE”时代下,QE如何破茧重生》
杂文笔记<"去QE"时代下,QE如何破茧重生> "去QE"时代下,QE如何破茧重生 https://mp.weixin.qq.com/s?__biz ...
- 「USACO08DEC」「LuoguP2922」秘密消息Secret Message(AC自动机
题目描述 Bessie is leading the cows in an attempt to escape! To do this, the cows are sending secret bin ...
- Data Grip 使用--->创建数据库连接
1. 简介 Data Grip 是一款类似于Workbench的数据库设计工具,可以用来对常用的数据管理系统(MySQL/Oracle/Postgresql...)进行操作. 2. 利用DataG ...
- opencv报错 error: (-215) size.width>0 && size.height>0 in function cv::imshow
使用opencv读取摄像头并且显示事出现此问题: 后来发现是图像为空时的错误,加入: if(!frame.empty()) imshow("video",frame); 完整的代码 ...
- AndroidStudio启动时不自动打开项目
取消勾选Reopen last project on startup选项 点击 OK 就行了
- webSocket 简单介绍
WebSocket :WebSocket协议支持(在受控环境中运行不受信任的代码的)客户端与(选择加入该代码的通信的)远程主机之间进行全双工通信. 简单的说 ...
- Matcher的replaceAll ()/appendReplacement()/appendTail()详细举例
直接上例子: package com.dajiangtai.djt_spider.util; import java.util.regex.Matcher;import java.util.regex ...
- C# 移除string[] 数组中的指定元素
本文转载自 http://www.cnblogs.com/jcdd-4041/p/3279531.html 第一步:先把string[] 转换成 ArrayList 第二步:移除指定元素 第三步 ...
- junit 直接执行测试方法报错
在eclipse中,直接右击test1->Run As->Junit Test,报下面的错: java.lang.NoSuchMethodError: org.junit.runner.R ...
- 判断ip地址是否为内网ip或局域网ip
bool IsLanIp(string& ip) { ,) == ,) == ,) == "192.") { return true; } else { return fa ...