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