Ios-model Data structure

Source: Internet
Author: User

Main role: Simplified VC code, easy to request data in the field of the increase, deletion, search, search, and post-code maintenance.

First, build model.

Create a Placeordermodel that inherits from NSObject

  #import  <foundation/foundation.h>@ Interface   placeordermodel:nsobject//ensure that the fields below are the same as the requested fields and can be used directly when adding new fields. The new field has no effect on the old field @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*  @end  
#import "PlaceOrderModel.h"@implementationPlaceordermodel+ (Instancetype) Modelwithdic: (Nsmutabledictionary *) dic{Placeordermodel*model=[[Placeordermodel alloc]init];    [Model Setvaluesforkeyswithdictionary:dic]; returnmodel;}-(void) SetValue: (ID) value Forundefinedkey: (NSString *) key{if([Key isequaltostring:@""]) {NSLog (@"data is not correct"); }    }

Second, in the VC call 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 Data structure

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.