主要作用:简化VC代码,便于请求数据中字段的增、删、查、找,以及后期代码维护。

一、构建Model。

创建继承于NSObject的PlaceOrderModel

#import <Foundation/Foundation.h>

@interface PlaceOrderModel : NSObject

//保证下面的字段和请求的字段相同即可,添加新字段时可直接使用,新字段对旧字段没有影响
@property (nonatomic,strong) NSString * provinceName;
@property (nonatomic,strong) NSString * cityName;
@property (nonatomic,strong) NSString * countyName;
@property (nonatomic,strong) NSString * unitName; @property (nonatomic,strong) NSString * address;
@property (nonatomic,strong) NSString * contact;
@property (nonatomic,strong) NSString * phone; +(instancetype)ModelWithDic:(NSMutableDictionary*)dic; @end
#import "PlaceOrderModel.h"

@implementation PlaceOrderModel

+(instancetype)ModelWithDic:(NSMutableDictionary *)dic
{
PlaceOrderModel *model=[[PlaceOrderModel alloc]init];
[model setValuesForKeysWithDictionary:dic];
return model;
} -(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
if ([key isEqualToString:@""]) {
NSLog(@"数据不对");
} }

二、在VC中调用PlaceOrderModel

                    PlaceModel = [PlaceOrderModel ModelWithDic:_dataSouce[i]];
NSString * cityName = nil;
if ([PlaceModel.provinceName isEqualToString:PlaceModel.cityName]) {
cityName = [NSString stringWithFormat:@"%@%@",PlaceModel.provinceName,PlaceModel.countyName];
}else{
cityName = [NSString stringWithFormat:@"%@%@%@",PlaceModel.provinceName,PlaceModel.cityName,PlaceModel.countyName];
} cell.CityName.text = cityName;
cell.AddressName.text = PlaceModel.address;
NSString * people = [NSString stringWithFormat:@"%@ %@",PlaceModel.contact,PlaceModel.phone];
cell.PeopleName.text = people;

ios-model数据结构的更多相关文章

  1. 教程视频、项目源码、全部干货【微信小程序、React Native、Java、iOS、数据结构】

    把我收藏多年的教学视频.项目源码分享给大家,大神就可以忽略了,很多东西都是基础性的,都是期初学习阶段收集的东西. 微信小程序(入门级,有web前端基础的人群): 链接: https://pan.bai ...

  2. IOS底层数据结构--class

    一.类的数据结构 Class(指针) typedef struct objc_class *Class; /* 这是由编译器为每个类产生的数据结构,这个结构定义了一个类.这个结构是通过编译器在执行时产 ...

  3. IOS model的getter和setter方法

    总结: 当使用 self.str1 = @"xxx";时, 系统自动调用 setter方法 param_str = self.str1; 自动调用getter方法注意: 只在对象点 ...

  4. IOS-底层数据结构

      Objective-C底层数据结构 类的数据结构 Class(指针) typedef struct objc_class *Class; /* 这是由编译器为每个类产生的数据结构,这个结构定义了一 ...

  5. Qt Model/View(官方翻译,图文并茂)

    http://doc.trolltech.com/main-snapshot/model-view-programming.html 介绍 Qt 4推出了一组新的item view类,它们使用mode ...

  6. (转)Qt Model/View 学习笔记 (一)——Qt Model/View模式简介

    Qt Model/View模式简介 Qt 4推出了一组新的item view类,它们使用model/view结构来管理数据与表示层的关系.这种结构带来的 功能上的分离给了开发人员更大的弹性来定制数据项 ...

  7. [Draft]iOS.Architecture.16.Truth-information-flow-and-clear-responsibilities-immutability

    Concept: Truth, Information Flow, Clear Responsibilities and Immutability 1. Truth 1.1 Single Source ...

  8. iOS面试高薪,进阶 你会这些呢嘛?(持续更新中)

    这个栏目将持续更新--请iOS的小伙伴关注!做这个的初心是希望能巩固自己的基础知识,当然也希望能帮助更多的开发者! 基础>分析>总结 面试 iOS常见基础面试题(附参考答案) iOS底层原 ...

  9. mvc+webapi 项目架构

    首先项目是mvc5+webapi2.0+orm-dapper+ef codefirst+redis+quartz.net+actionmq. 1.项目框架层次结构: 这个mvc项目根据不同的业务和功能 ...

  10. ruby -检查数据类型

    HashObj={","language"=>"zh","make"=>"Apple"," ...

随机推荐

  1. http://www.roncoo.com/course/view/a09d8badbce04bd380f56034f8e68be0

    http://www.roncoo.com/course/view/a09d8badbce04bd380f56034f8e68be0

  2. 线段树(多棵) HDOJ 4288 Coder

    题目传送门 题意:集合,add x, del x, 求和 分析:首先,暴力可以过这题.用上线段树能大大降低时间的消耗,具体就是类似开了5棵线段树,每个节点都有5个空间,表示该区间的id%5后的和,区间 ...

  3. figure元素

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. 基于Theano的DL的开源小框架:Dragon

    Link:https://github.com/neopenx/Dragon 起因 最近看了Hinton的Dropout,发现原来的乱代码只能在Softmax层前面加Dropout.索性把整个Thea ...

  5. HDU 1452 (约数和+乘法逆元)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1452 题目大意:求2004^X所有约数和,结果mod 29. 解题思路: ①整数唯一分解定理: 一个 ...

  6. CSS雪碧,即CSS Sprite 简单的例子

    CSS Sprite生成工具 http://pan.baidu.com/s/1gdGQwiJ 工具可将多幅图片整合一张,并生成CSS. HTML代码 <style> .img{backgr ...

  7. Codeforces Round #246 (Div. 2) B. Football Kit

    题目的意思是求出每个队穿主场衣服和客场衣服的次数 每个队作为主场的次数是n-1,作为客场的次数是n-1 当每个队打主场的时候肯定穿的主场衣服 当每个队打客场时,如果客场与主场的衣服不同,则穿客场衣服 ...

  8. 【JAVA】Math.Round()函数常见问题“四舍5入”

    java.lang.Math.Round()使用时候,处理方式整理,方便以后查找   /**  * 测试函数 2014-01-10  */ public class TestMath {     pu ...

  9. [LintCode] Generate Parentheses 生成括号

    Given n pairs of parentheses, write a function to generate all combinations of well-formed parenthes ...

  10. Oracle恢复删除数据 && connect by 树形结构查询

    1.一个表中根据以父子级别关系查询显示出来(如图) select t.* from department t CONNECT BY PRIOR t.depid=t.supdepid ; --这样也可以 ...