is there any way to create model classes(wrapper) of dictionary or json responce? because in my app there are many webservices and all WS contains big data. if i am creating all the time one by one it takes much time to create NSObject Class with Checking Null data and Encode-Decode Object. either please suggest me it is right way to create all NSObject manually? i can't want to parse direct dictionary. Thanks.
finally i got very easy and fast Model Class generator tool for iOS and Android both. just copy and paste your responce and get Model Class from tool.
Copy your JSON Responce from browser.(responce must be JSON Validated).
paste in Json Accelerator >> Click Generate and Save With Your Modelname.
Use Like This >>>
For Example Your JSON Respoce Dictionary is
{"employees":[
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter", "lastName":"Jones"}
]}
make Employee Array and then create Object With Created Model Classes like below code and you have to use For loop
or enumerateObjectsUsingBlock
any one for create and then Add in Mutable Array.
NSArray *arrTemp = [NSArray arrayWithArray:yourResponceDict[@"employees"]]; NSMutableArray *myMutableArray = [NSMutableArray array];
[arrTemp enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
Employee *aObj = [Employee modelObjectWithDictionary:obj];
[myMutableArray addObject:aObj];
}];
This Tool is Very easy and Time Saving For Creating Json Object Classes for parsing data anywhere in Development.
You can use modules like BaseModel, ObjectMapper or EVReflection open source projects for this purpose. They are all open source modules that you can use in your project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With