I think you are new to objective-C programming. I'm trying to explain how you should retrieve the data.
First create a Model class. Model class object will be generated from server response.
The class should be look like this,
YourModelClass.h file,
#import <Foundation/Foundation.h>
@interface YourModelClass : NSObject
@property (nonatomic, strong) NSNumber *id;
@property (nonatomic, strong) NSString * salutation;
@property (nonatomic, strong) NSString * firstName;
@property (nonatomic, strong) NSString * lastName;
@property (nonatomic, strong) NSString * email;
————————
————————
————————
————————
@property (nonatomic, strong) NSString * vehicleRegNo;
- (instancetype)initWithDictionary: (NSDictionary *) dictionary;
@end
YourModelClass.m file,
#import "YourModelClass.h"
@implementation YourModelClass
- (instancetype)initWithDictionary:(NSDictionary *)dictionary
{
self = [super init];
if (self) {
self.dictionary = dictionary;
}
return self;
}
- (void)setDictionary:(NSDictionary *)dictionary{
self.id = dictionary[@“id”] ? : @“”;
self.salutation = dictionary[@“salutation"] ? : @“”;
self.firstName = dictionary[@"first_name"] ? : @“”;
————————
————————
————————
————————
self.vehicleRegNo = dictionary[@"vehicle_reg_no"] ? : @“”;
}
@end
Now suppose you have get server response as Data.
With the data you can populate your model object like this,
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:YourURL];
[request setHTTPMethod:@"GET"];
NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfiguration];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler: ^(NSData *data, NSURLResponse *response, NSError *error) {
if (!error)
{
NSError *jsonError;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&jsonError];
if(!jsonError)
{
if([json[@"data"] isKindOfClass:[NSDictionary class]])
{
YourModelClass *modelObject = [[YourModelClass alloc] initWithDictionary:json[@"data"]];
}
}
}
}];
[task resume];