1. plist→ Model Array
Reference #import "MJExtension.h" in the controller
Model array = [model class name objectarraywithfilename:@ "filename. plist"];
2. Optimization of NSLog, solve the problem when debugging, print model, only print out memory address
How to use: in a. m file of a model class, reference #import "MJExtension.h"
Between the @implementation and the @end, write Mjlogallivrs.
3. Optimization of the nscoding, no need to write cumbersome solutions and archiving methods
How to use: in a. m file of a model class, reference #import "MJExtension.h"
Between the @implementation and the @end, write Mjcodingimplementation.
4. Dictionary arrays → model arrays
4.1 Scene One: [ dictionary 1,
Dictionary 2,
Dictionary 3 ]
If each dictionary is a model, you can use the
Nsarray *modelarray = [model class name Objectarraywithkeyvaluesarray: Field array];
4.2 Scene Two: On the basis of scenario one, each dictionary has an array (assuming the array's key value is Arrayname), the array contains several identical models, using the following method
How to use:
First, in the model class. m file, introduce #import "MJExtension.h"
And then write between the @implementation and the @end.
-(Nsdictionary *) Objectclassinarray
{
return @{@ "Arrayname": [Model Class name class]};
}
5.If the server passed the dictionary in the Dictionary array of key, is the keyword in OC, and the premise of using mjextention is that the model of the property name and array of key is consistent.(Case sensitive), what to do?
Using Replacedkeyfrompropertyname
How to use: 1. Introducing "MJExtension.h" to the model class. m file
2. Implementation methods
+ (Nsdictionary *) replacedkeyfrompropertyname
{
Return @{@ "non-keyword attribute name": @ "Array of key"};
}
6. Single dictionary → single model
+ (Instancetype) objectwithkeyvalues: (Nsdictionary *) keyvalues
Mjextension use of IOS JSON parsing framework