Jsonmodel Simple Example

Source: Internet
Author: User

  productmodel.h//  jsonmodel////  Created by Feng on 15/7/20.//  Copyright (c) 2015 Feng. 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 Feng on 15/7/20.//  Copyright (c) 2015 Feng. All rights reserved.//#import "ProductModel.h" @implementation productmodel+ (Jsonkeymapper *) keymapper{    return [[ Jsonkeymapper Alloc] initwithdictionary:@{@ "id": @ "ID1", @ "SSS": @ "xxxxx"}];} @end

  test1model.h//  jsonmodel////  Created by Feng on 15/7/20.//  Copyright (c) 2015 Feng. 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 Feng on 15/7/20.//  Copyright (c) 2015 Feng. 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 Feng on 15/7/20.//Copyright (c) 2015 Feng.  All rights reserved.//#import <UIKit/UIKit.h> @interface viewcontroller:uiviewcontroller@end//// viewcontroller.m//jsonmodel////Created by Feng on 15/7/20.//Copyright (c) 2015 Feng. 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 resourcesThat can is recreated.} @end

Jsonmodel Simple Example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.