In general, iOS has a partial page load process, creating a model then associating the nib file with the model and then quickly getting to the control instance on the nib file. The Action Generation page.
But the original content is not directly through the JSON get model can only generate a dictionary. Then convert to model. The following method is the process of converting a dictionary to model.
Convert a dictionary to model
-(BOOL) Reflectdatafromotherobject: (Nsdictionary *) dic{unsignedintOutcount, I; objc_property_t*properties = Class_copypropertylist ([selfclass], &outcount); for(i =0; i < Outcount; i++) {objc_property_t property=Properties[i]; NSString*propertyname =[[NSString alloc] Initwithcstring:property_getname (property) encoding:nsutf8stringencoding]; NSString*propertytype =[[NSString alloc] Initwithcstring:property_getattributes (property) encoding:nsutf8stringencoding]; if([[DiC AllKeys] containsobject:propertyname]) {IDValue =[dic Valueforkey:propertyname]; if(! [Value Iskindofclass:[nsnullclass]] && Value! =Nil) { if([Value Iskindofclass:[nsdictionaryclass]]) { IDPro =[self createinstancebyclassname:[self getclassname:propertytype]]; [Pro Reflectdatafromotherobject:value]; [Self Setvalue:pro forkey:propertyname]; }Else{[self setvalue:value forkey:propertyname]; }}}} free (properties); return true;}
Other two helper type methods
-(NSString *) GetClassName: (NSString *) attributes{NSString*type = [Attributes Substringfromindex:[attributes Rangeofregex:@"\ ""].location + 1]; Type = [Type Substringtoindex:[type rangeofregex:@"\""].location]; returntype;}-(ID) Createinstancebyclassname: (NSString *) className {nsbundle*bundle =[NSBundle Mainbundle]; Class AClass=[bundle Classnamed:classname]; IDAninstance =[[AClass alloc] init]; returnaninstance;}
Convert model to Dictionary
-(Nsdictionary *) convertmodeltodictionary{ *dic = [[Nsmutabledictionary alloc] init]; for inch [self PropertyKeys]) { id propertyvalue = [self valueforkey:key]; // The value is not nsnull and is not nil [dic setobject:propertyvalue Forkey:key]; } return DiC;}