0

I am new to xcode kindly help me to correct the error my code is below,

-(void)XYZ:(NSString *)id1
{
    id2 = [id1 intValue];
    [self Vehicles:id2];

}

-(NSArray *)Vehicles:(NSInteger) id2
{

    NSString *urlString=[NSString stringWithFormat:@"http://www.xxxx.com/xxxx/vehiclelist.php?uid=%d&format=json",id2];
    NSURL *url=[NSURL URLWithString:urlString];
    NSData *data=[NSData dataWithContentsOfURL:url];
    NSError *error;
    NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
    NSArray *results = [json valueForKey:@"posts"];
    return results;
}

And i pass the id value from the login vied controller the code is,

if(stat!=0&&id2!=0&&[Username length]!=0&&[Password length]!=0)
{
    Services *loc = [[Services alloc] initWithNibName:@"Services" bundle:nil]; 
    loc.modalPresentationStyle = UIModalPresentationCurrentContext;
    loc.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentViewController:loc animated:YES completion:Nil];
    MyVchicle *about = [[MyVchicle alloc]  initWithNibName:@"MyVchicle" bundle:nil];
    about.modalPresentationStyle = UIModalPresentationCurrentContext;
    about.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentViewController:about animated:YES completion:Nil];
    [loc XYZ:id1];
}

Thanks in advance.

Ragul
  • 39
  • 1
  • 6

1 Answers1

0

For sending data from one ViewController to another, follow these steps :

  1. Declare a variable in your DestinationViewController.
  2. Connect a segue from your SourceViewController to your DestinationViewController.
  3. Now in your SourceViewController, write this function :
 -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
        {
        DestinationViewController *destController = [segue destinationViewController];
        destController.varName = @"passThisValue";
        }
  1. The above function declares your destinationViewController and assigns a value to the variable of the destinationViewController that we declared above.

This should get you going. Hope this helps.

You can refer to this link.

Passing Data between View Controllers

Community
  • 1
  • 1
Matt Murdock
  • 3,203
  • 6
  • 20
  • 34