I am new to IOS. My first class is ViewController.I want to pass user_id from this class to snsViewController class. But i am getting null values when i am using @property.
I m writing this code in snsViewController.m
ViewController *objViewController=[[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
[objViewController jsonPost:getpostJson];
Plz suggest me some solution on this
I have written this code in ViewController.m
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
respstring = [[NSString alloc]initWithData:loginJsonData encoding:NSUTF8StringEncoding];
NSLog(@"*******: %@",respstring);
SBJsonParser *objSBJsonParser = [[SBJsonParser alloc]init];
json = [[NSDictionary alloc]initWithDictionary:[objSBJsonParser objectWithString:respstring]];
NSLog(@"json: %@",json);
/}
//-(void)loginjonresponse
// {
NSNumber *error = [json objectForKey:@"error"];
if([error intValue] == 0)
{
NSLog(@"u r connected with webserver ");
}
else
{
NSLog(@"connection fail");
}
NSString *value=[json objectForKey:@"value"];
NSLog(@"value: %@",value);
if (value ==(id)[NSNull null] || value==nil)
{
NSLog(@"login fail");
}
else
{
NSString *user_details=[[json objectForKey:@"value"]objectForKey:@"user"];
// NSLog(@"user_deails%@",user_details);
if ([user_details isEqual:@"false"])
{
[self alertStatus:@"Please enter correct username and password" :@"Login Failed!"];
NSLog(@"incorrect user name password");
}
else
{
user_id=[[[json objectForKey:@"value"]objectForKey:@"user"]objectForKey:@"id"];
NSLog(@"user_id: %@",user_id);
firstname=[[[json objectForKey:@"value"]objectForKey:@"user"]objectForKey:@"firstname"];
NSLog(@"firstname: %@",firstname);
lastname=[[[json objectForKey:@"value"]objectForKey:@"user"]objectForKey:@"lastname"];
NSLog(@"lastname: %@",lastname);
email=[[[json objectForKey:@"value"]objectForKey:@"user"]objectForKey:@"email"];
NSLog(@"email: %@",email);
currentroll_id=[[[json objectForKey:@"value"]objectForKey:@"user"]objectForKey:@"current_roll_id"];
NSLog(@"current_roll_id: %@",currentroll_id);
currentcourse_id=[[[json objectForKey:@"value"]objectForKey:@"user"]objectForKey:@"current_course_id"];
NSLog(@"current_course_id: %@",currentcourse_id);
// [self classlist];
#pragma After successful login move to sns page
snsViewController *objsnsViewController=[[snsViewController alloc]initWithNibName:@"snsViewController" bundle:nil];
[self.view addSubview:objsnsViewController.view];
}
}
}
In this code i m getting user_id value.I want to pass this value to snsViewController.