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
Dhrumil
  • 3,221
  • 6
  • 21
  • 34
  • Sorry am very new to xcode can u guide me a demo for pass the value & i am not using the storyboard. Thank you – Ragul Jun 19 '14 at 05:21
  • Yes the same way am also used for passing but it shows error – Ragul Jun 19 '14 at 05:34
  • Can you show the error log ? Maybe that could help on identifying the problem. – Dhrumil Jun 19 '14 at 05:41
  • The value is sucessfuly passed but the error comes only when it try to move to the next page. – Ragul Jun 19 '14 at 05:46
  • I am not getting more out of it now since you are not using a storyboard. Btw, just give it a try with a storyboard. That might work out in your case. Will post some links if they are helpful. Keep trying. – Dhrumil Jun 19 '14 at 05:47
  • Sorry now am in the middle of the project so i cant use the storyboard – Ragul Jun 19 '14 at 05:50
  • Lets see. I will have a look into it. Need some time for it as I always work around with storyboards. Keep trying. – Dhrumil Jun 19 '14 at 05:53
  • @Ragul your "MyVchicle" viewcontroller not calling due to error "Unbalanced calls to begin/end appearance transitions for ." then why you written their??? Also why you are calling two view controller one after another?? – Ashwinkumar Mangrulkar Jun 19 '14 at 06:36