Hi i am getting the response from my server successfully.i need to access the user_id send by the server in my app.
check my code:
NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate: nil delegateQueue: [NSOperationQueue mainQueue]];
NSURL * url = [NSURL URLWithString:@"my url"];
NSMutableURLRequest * urlRequest = [NSMutableURLRequest requestWithURL:url];
NSString * params=[[NSString alloc]initWithFormat:@"mobile=%@",[self.reqnum text ]];
NSLog(@"%@",params);
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setHTTPBody:[params dataUsingEncoding:NSUTF8StringEncoding]];
NSURLSessionDataTask * dataTask =[defaultSession dataTaskWithRequest:urlRequest
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
NSLog(@"Response:%@ %@\n", response, error);
if(error == nil)
{
NSString * text = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
NSLog(@"Data = %@",text);
[[NSUserDefaults standardUserDefaults]setObject:@"Y" forKey:@"login"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
}];
[dataTask resume];
for this code i am getting the response like:
here i need to access the user_id in my app .so can i get that particular user_id.
Thank You.
If you want to use the value in other classes then :
First create a data Model Class, parse the data dictionary/JSON and store it. Using the completion block you can return the specific/received user_id to the caller.
Here you are getting in JSON, you can parse it and get the desired data: