主要作用:简化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. 泛型容器单元(Generics.Collections)[2]: TQueue<T> 队列列表

    TQueue 和 TStack, 一个是队列列表, 一个是堆栈列表; 一个是先进先出, 一个是先进后出. TQueue 主要有三个方法.一个属性:Enqueue(入列).Dequeue(出列).Pee ...

  2. S5中新增的Array方法详细说明

      ES5中新增的Array方法详细说明 by zhangxinxu from http://www.zhangxinxu.com 本文地址:http://www.zhangxinxu.com/wor ...

  3. PL/SQL 循环结构

    (1)LOOP...EXIT...END语句示例: control_var:; LOOP then EXIT; END IF; control_var:; END LOOP; 上述,初始化contro ...

  4. [深入浅出WP8.1(Runtime)]应用实例——移动截图

    10.2应用实例——移动截图 移动截图例子是实现一个把一张图片的某个部分截取出来的功能,并且用户可以选定截取的图片区间.那个该例子会使用ManipulationDelta事件来实现对截取区间的选择.然 ...

  5. asp.net mvc4 HTTP Error 403.14

    asp.net mvc4项目部署到II&上时,出现HTTP Error 403.14 - Forbidden - The Web server is configured to not lis ...

  6. BZOJ1110: [POI2007]砝码Odw

    Description 在byteotian公司搬家的时候,他们发现他们的大量的精密砝码的搬运是一件恼人的工作.公司有一些固定容量的容器可以装这些砝码.他们想装尽量多的砝码以便搬运,并且丢弃剩下的砝码 ...

  7. iOS 两种易混淆的存储路径

    一,NSBundle 1>我们可以通过解压等操作获取 NSBundle 中的内容. 2>NSBundle主要是包路径,也就是代码编译后的 imge 和 sb 资源文件... 3>例如 ...

  8. be supposed to

    be supposed to 期望; 認為必須, 認為應該; 認為...... 期望; 認為必須, 認為應該; 認為...必要 Am I supposed to clean all the rooms ...

  9. UpdatePanel完成后调用js

    引言: asp.net 微软引入了UpdatePanel 使用起来很方便 如果 我们想UpdatePanel加载完成后做一些事情 需要使用js <script type="text/j ...

  10. JSP 页面缓存以及清除缓存

    一.概述 缓存的思想可以应用在软件分层的各个层面.它是一种内部机制,对外界而言,是不可感知的. 数据库本身有缓存,持久层也可以缓存.(比如:hibernate,还分1级和2级缓存) 业务层也可以有缓存 ...