ios-model数据结构
主要作用:简化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数据结构的更多相关文章
- 教程视频、项目源码、全部干货【微信小程序、React Native、Java、iOS、数据结构】
		把我收藏多年的教学视频.项目源码分享给大家,大神就可以忽略了,很多东西都是基础性的,都是期初学习阶段收集的东西. 微信小程序(入门级,有web前端基础的人群): 链接: https://pan.bai ... 
- IOS底层数据结构--class
		一.类的数据结构 Class(指针) typedef struct objc_class *Class; /* 这是由编译器为每个类产生的数据结构,这个结构定义了一个类.这个结构是通过编译器在执行时产 ... 
- IOS model的getter和setter方法
		总结: 当使用 self.str1 = @"xxx";时, 系统自动调用 setter方法 param_str = self.str1; 自动调用getter方法注意: 只在对象点 ... 
- IOS-底层数据结构
		Objective-C底层数据结构 类的数据结构 Class(指针) typedef struct objc_class *Class; /* 这是由编译器为每个类产生的数据结构,这个结构定义了一 ... 
- Qt Model/View(官方翻译,图文并茂)
		http://doc.trolltech.com/main-snapshot/model-view-programming.html 介绍 Qt 4推出了一组新的item view类,它们使用mode ... 
- (转)Qt Model/View 学习笔记 (一)——Qt Model/View模式简介
		Qt Model/View模式简介 Qt 4推出了一组新的item view类,它们使用model/view结构来管理数据与表示层的关系.这种结构带来的 功能上的分离给了开发人员更大的弹性来定制数据项 ... 
- [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 ... 
- iOS面试高薪,进阶 你会这些呢嘛?(持续更新中)
		这个栏目将持续更新--请iOS的小伙伴关注!做这个的初心是希望能巩固自己的基础知识,当然也希望能帮助更多的开发者! 基础>分析>总结 面试 iOS常见基础面试题(附参考答案) iOS底层原 ... 
- mvc+webapi 项目架构
		首先项目是mvc5+webapi2.0+orm-dapper+ef codefirst+redis+quartz.net+actionmq. 1.项目框架层次结构: 这个mvc项目根据不同的业务和功能 ... 
- ruby -检查数据类型
		HashObj={","language"=>"zh","make"=>"Apple"," ... 
随机推荐
- Y86模拟器安装
			Y86模拟器安装 这周需要学习Y86下的指令集开发,Y86和x86可以说是孪生兄弟,但是还是存在着一些小的差别.接下来介绍如何进行linux-debian平台下的Y86模拟器安装. 虚拟机VMware ... 
- http://www.cnblogs.com/younggun/archive/2013/07/16/3193800.html
			http://www.cnblogs.com/younggun/archive/2013/07/16/3193800.html 
- address元素
			<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ... 
- 斑点检测(LoG,DoG)(下)
			斑点检测(LoG,DoG)(下) LoG, DoG, 尺度归一化 上篇文章斑点检测(LoG,DoG)(上)介绍了基于二阶导数过零点的边缘检测方法,现在我们要探讨的是斑点检测.在边缘检测中,寻找的是二阶 ... 
- BZOJ3172[Tjoi2013]单词 题解
			题目大意: 求一些字符串在一段文章中出现的次数. 思路: AC自动机的经典应用,建完自动机直接将队列里的元素调Fail指针记录即可. 代码: #include<cstdio> #inclu ... 
- ACM:统计难题  解题报告-字典树(Trie树)
			统计难题 Time Limit:2000MS Memory Limit:65535KB 64bit IO Format:%I64d & %I64u Submit Status ... 
- 2分钟 windows下sublime text 3安装git插件:
			12:35 2015/11/182分钟 windows下sublime text 3安装git插件:推荐博客:http://blog.csdn.net/naola2001/article/detail ... 
- 30秒修复Ubuntu菱形乱码问题
			将语言改为英文,我是按照第三种方式进行的,成功.参考博客: http://blog.sina.com.cn/s/blog_a126a955010180b8.html 
- TC SRM 591
			表示第一次在div1,我要记录一下... 木有挂0,第一题不怎么难的,读题读了20分钟,又想了20分钟,时间有点长,然后各种小心,然后得了140分.... 后两个题,根本木有看,貌似做出来的也不多.. ... 
- URAL 1244. Gentlemen(DP)
			题目链接 这题不难啊...标记一下就行了.表示啥想法也没有. #include <cstring> #include <cstdio> #include <string& ... 
