Muthu Raj Muthu Raj - 1 year ago 86
iOS Question

getting NSException while passing data from one viewController to another viewController

I am passing a data from one viewController to another viewController. But it is throwing


Here is my code.


NSString *empid1 = [dataDict objectForKey:@"EmployeeId"];
NSLog(@"empid %@",empid1); //it prints 161.
DashBoardViewController *dash = [[DashBoardViewController alloc]initWithNibName:@"DashBoardViewController" bundle:nil];
dash.empid = empid1;


@property (strong, nonatomic) NSString * empid;


NSString *strURL=[NSString stringWithFormat:@"",_empid];

It throws data is
.Any help will be appreciated.

Answer Source

plz use this you are using storyboard

pass your value like this

 [self performSegueWithIdentifier:@"DashBoardViewController" sender:[dataDict objectForKey:@"EmployeeId"]];

use this method when you use performSegueWithIdentifier

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    if ([segue.identifier isEqualToString:@"DashBoardViewController"])
        DashBoardViewController *dash= segue.destinationViewController;
      dash.empid =(NSString *)sender;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download