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"," ...
随机推荐
- js-原型以及继承小案例
function human(name,tall){ this.name=name; this.tall=tall; this.toSleep=function(){ alert('no sleep' ...
- POJ3184 Ikki's Story I - Road Reconstruction(最大流)
求一次最大流后,分别对所有满流的边的容量+1,然后看是否存在增广路. #include<cstdio> #include<cstring> #include<queue& ...
- DrawingContext.Pop Method
The following example shows the effect of the Pop command. using System; using System.Windows; using ...
- Eclipse: How to Navigating Java call stack in Eclipse
Link: http://stackoverflow.com/questions/3256369/navigating-java-call-stack-in-eclipse 解决方法: In the ...
- [WP8.1UI控件编程]Windows Phone VirtualizingStackPanel、ItemsStackPanel和ItemsWrapGrid虚拟化排列布局控件
11.2.2 VirtualizingStackPanel.ItemsStackPanel和ItemsWrapGrid虚拟化排列布局控件 VirtualizingStackPanel.ItemsSta ...
- 啥时候js单元测试变的重要起来?
作为一个菜鸟,开这个专栏其实不合适,但又突然发现这个比以往任何时候都重要,所以还是写写我的感受 首先,在传统的pc上也有大量的web站点和各种项目都有复杂的js,但是基本不做单元测试,为啥呢?因为传统 ...
- iOS 上线被拒收集
根据上线被拒的原因 自己 也在慢慢总结 希望对各位有所帮助 1)QQ 微信 等第三方平台 必须要做是否安装应用的检测
- 深入浅出-Android系统移植与平台开发(一)- Android4.0系统的下载与编译
作者:唐老师,华清远见嵌入式学院讲师. 一.Android4.0系统的下载与编译 Android系统的下载与编译,Google的官方网站上已经给出了详细的说明,请参照Android的官方网址: htt ...
- OSG中的示例程序简介
OSG中的示例程序简介 转自:http://www.cnblogs.com/indif/archive/2011/05/13/2045136.html 1.example_osganimate一)演示 ...
- MongoDB使用操作
一.mongodb常用命令 http://www.cnblogs.com/cxd4321/archive/2011/06/24/2089051.html 二.MongoDB基本使用 http://ww ...