0

I built a hierarchy of viewControllers and in my storyboard scene I need to move two nibs ahead. The problem is that after I return to controller, it seems to lose the id that is important to retrieve required data from DB. One nib ahead OK, but after two nibs NO.

Also, after returning neither -viewWillAppear nor -viewDidLoad get fired. Thank you in advance.

I checked if segue really feeds the right data. The final nib gets right id. So, problem isn't data lost while segue.

CODE: First nib receives data from main nib. viewWillAppear fetches data from DB and fills up the labels etc.

Navigation begins here.

if([segue.identifier isEqualToString:@"toDublicates"])
{
    DublicatesViewController *controller=(DublicatesViewController*)[segue destinationViewController];
    // controller is tableViewController
    controller.typeID=self.typeID;
    controller.nominalID=self.nominalID;
    controller.regionID=self.regionID;
    controller.subCountryID=self.subCountryID;
    KMObj *obj=[self.arr objectAtIndex:0];
    controller.title=[NSString stringWithFormat:@"Dublicates | KM%@",obj.kmRef];
}

Second nib. NSLog reveals that data is OK. Moving to final nib

if([segue.identifier isEqualToString:@"toCreateDublicate"])
{
    NewDublicateViewController *controller=(NewDublicateViewController*)[segue destinationViewController];
    controller.typeID=self.typeID;
    controller.subCountryID=self.subCountryID;
    controller.nominalID=self.nominalID;
    controller.regionID=self.regionID;
    controller.numberOfExistingDublicates=[_arr count];
}

The method that fires in final controller

-(void)back {

[self.navigationController popViewControllerAnimated:YES];
}
NCFUSN
  • 1,624
  • 4
  • 28
  • 44
  • show the code for the setup and the navigation change – Wain May 27 '13 at 18:56
  • Popping a view controller off the navigation stack will not cause any lifecycle methods to be called on the underlying view controller, so that behavior is correct. To help your further, we need code. – Scott Berrevoets May 27 '13 at 18:56
  • Code added. Hope it will clear the situation. – NCFUSN May 27 '13 at 19:07
  • After returning back I get my labels blank. – NCFUSN May 27 '13 at 19:08
  • You're using the term nib wrongly -- a nib is a file, I think you mean controller or scene. Are all of these controllers in one storyboard? Also, are these two segues the only segues you have in the storyboard? – rdelmar May 27 '13 at 19:51
  • Yes, probably. I call scene nibs. I have more segues, but they work correct. – NCFUSN May 27 '13 at 19:55
  • So what exactly is the problem? If I understand correctly, you're going from NewDublicateViewController to DublicateViewController with popViewControllerAnimated, is that correct? And you have some labels in that controller that are empty when you come back? – rdelmar May 27 '13 at 19:57
  • KMController -> DublicatesViewController -> NewDublicateViewController. After coming back the labels on KMController getting blank. – NCFUSN May 27 '13 at 20:01
  • How are you coming back? Your question says that the (void)back method is in the final controller, and popViewControllerAnimated will take you back only one controller. So how are you getting back to KMController? – rdelmar May 27 '13 at 20:03
  • same -back meth exists on all controllers. – NCFUSN May 27 '13 at 20:07
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/30710/discussion-between-rdelmar-and-nathan) – rdelmar May 27 '13 at 20:08
  • Are you resetting the id in the third controller? – km3h May 28 '13 at 14:27
  • http://stackoverflow.com/questions/5210535/passing-data-between-view-controllers?rq=1 – daksh_019 Mar 21 '15 at 11:08

0 Answers0