Generating POJO classes Procedure
Purpose :
Pojo Classes Automation will provide all data models classes with robust coding standards from Json response. we can create all related model classes with couple of clicks.
Steps to generate POJO Classes.
1.Get the response from webservice in JSON string format.
2.Install JSON Accelerator (mac App). and Launch it
3 copy paste the JSON format in JSON Accelerator app.
5.Click on Genarate files and Set the Folder path to where has to generate the POJO classes
5.Make sure to select objective c or core data (objective c )
- On selecting objective c it will generate data models classes with structure of POJO classes.
- On selecting core data (objective c ) it will generate the data models classes for core data model.
6.Give the Name of Main base “class name” and also specify the Prefix identifier in input fields
7.Submit by chose the folder path to save,.
Integration of generated pojo Classes to Project.
1.Add the POJO generated classes to Project.
2.Call Respective Data filling by allocating the dictionary.
#import "DataModels.h"
self.arrMeasuremntsObjects = [[NSMutableArray alloc] init];
if ([resultData isKindOfClass:[NSArray class]]) {
NSLog(@"Responce data contains %lu objects ",(unsigned long)[resultData count]);
for (id data in resultData) {
MTMeasurements *objMesaurement = [[MTMeasurements alloc] initWithDictionary:data];
[self.arrMeasuremntsObjects addObject:objMesaurement];
}
NSLog(@"Coutnt Of Convenrted Objects %li",[self.arrMeasuremntsObjects count]);
}
Source code : https://github.com/SrinivasaLadi/pojoResponceHandler