-1

I am beginning wit iOS and trying getting to understand how delegates work for passing data. I understand how to pass Data from ControllerA to ControllerB.

Now what would be the best approach for passing data from ControllerA to Controller B and then to ControllerC. Data would be exactly the same.

I have spent 3,4 hours and can't get a solution to this. I looked around and I did not find enough formation. A link to a sample would be also very helpful

Edu
  • 25
  • 9
  • What are you doing between B and C ? You push or present a view like you do from A to B ? – Jordan Montel Nov 27 '13 at 10:37
  • for a reference you can see this http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers – wasim Nov 27 '13 at 10:38
  • well, I don't think I've understood the question... but the controllers could just have a property defined... could you post some code, so that I can better understand your problem? – Deboroh88 Nov 27 '13 at 10:38
  • @JordanMontel Yes I want to push it exactly the same way. It is a UIImage and I want it to display it on the screen the same as from A to B. – Edu Nov 27 '13 at 10:42
  • than you should have UIImage properties over all three controller, so simply you can assign UIImage to the next controller on the time of push. – Suryakant Sharma Nov 27 '13 at 10:44

2 Answers2

-1

Firstly you have to create a NSString in class B after that you can access the string like this to pass the value use this code :

- (IBAction) nextClass:(id) sender
{
ClassB *b = [[ClassB alloc] initWithNibName:@"ClassB" bundle:nil];

b.stringb = [NSString stringWithFormat:@"%@", put your string/array here to pass the value to next view controller];

[self.navigationController pushViewController:b animated:YES];

}
Gurpreet
  • 181
  • 6
-1

Firstly you have to create a object in class A And Same Object in Class B after that you can access the object like this to pass the value use this code :

#pragma mark prepareForSegue

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{

    if ([segue.identifier isEqualToString:@"classA"])
       {
         UITabBarController *tab = [segue destinationViewController];
         classA *a= [[ClassView alloc] init];
         a = (ClassView *)[[tab customizableViewControllers]objectAtIndex:0];
         a.object = object;

     }if ([segue.identifier isEqualToString:@"classB"])
         {
           UITabBarController *tab = [segue destinationViewController];
           classB *b= [[ClassView alloc] init];
           b = (ClassView *)[[tab customizableViewControllers]objectAtIndex:0];
           b.object = object;
     }if ([segue.identifier isEqualToString:@"classC"]) 
          {
           UITabBarController *tab = [segue destinationViewController];
           classC *c= [[ClassView alloc] init];
           c = (ClassView *)[[tab customizableViewControllers]objectAtIndex:0];
           c.object = object;
      }
}
Harjot Harry
  • 155
  • 8