JSONModel is a database that parses the Json data returned by the server.
Generally, the json data returned by the server is converted to the Model by writing a data conversion module, and the NSString data is converted to the Data Type of the property in the Model.
In this way, if you want to modify the server, you may need to modify two or three files.
The emergence of JSONModel is to complete this resolution at the design level.
Usage: Reference connection
JSONModel. m, the core part of its source code, is read as follows:
In
Function: returns nil if any errors or errors occur.
-()initWithDictionary:(NSDictionary*)dict error:(NSError** (! (err) *err = (![dict isKindOfClass:[NSDictionary (err) *err = self = (! (err) *err = NSArray* incomingKeysArray =* requiredProperties =* incomingKeys = JSONKeyMapper* keyMapper = NSMutableSet* transformedIncomingKeys =* transformedName = (NSString* requiredPropertyName transformedName = incomingKeys = (! JMLog( (err) *err = incomingKeys== (JSONModelClassProperty* property NSString* jsonKeyPath = (keyMapper) jsonKeyPath = jsonValue = (jsonValue==nil && property.isOptional== Class jsonValueClass = [jsonValue = (Class allowedType = (isValueOfAllowedType== JMLog( (err) *err = (property.type == nil && property.structName== ([[property.type ] isSubclassOfClass:[JSONModel NSError* initError = value = [[property.type alloc] initWithDictionary: jsonValue error:& (! (initError && err) *err = jsonValue = (! (err) *err = (property.isStandardJSONType && = (![jsonValue isKindOfClass:property.type] && !|| Class sourceClass = [JSONValueTransformer classByResolvingClusterClasses:[jsonValue NSString* selectorName = [NSString stringWithFormat:? property.structName : property.type), sourceClass]; SEL selector = clang diagnostic push clang diagnostic ignored "-Warc-performSelector-leaks" jsonValue = clang diagnostic pop [NSException exceptionWithName:, property.type, [self NSError* validationError == [self validate:& (doesModelDataValidate == (err) *err =