zoukankan      html  css  js  c++  java
  • 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
    
  • 相关阅读:
    复旦大学2016--2017学年第二学期(16级)高等代数II期末考试第八大题解答
    复旦大学2016--2017学年第二学期高等代数II期末考试情况分析
    16 级高代 II 思考题十的多种证明
    16 级高代 II 思考题九的七种解法
    Jordan 块的几何
    实对称阵可对角化的几种证明及其推广
    复旦大学高等代数在线课程2017--2018学年记录
    复旦高等代数II(16级)每周一题
    复旦大学2016--2017学年第一学期(16级)高等代数I期末考试第六大题解答
    复旦大学2016--2017学年第一学期(16级)高等代数I期末考试第七大题解答
  • 原文地址:https://www.cnblogs.com/0515offer/p/4665473.html
Copyright © 2011-2022 走看看