1

I implemented a navigation controller in my iPad app which works perfectly fine.

Now, on one view of the navigation stack I want to pass data to the parent view if popped to it.

I tried this in the child view controller:

(property of dataArray +synthesize in both views)

-(void)viewWillDisappear:(BOOL)animated
{

if([self isMovingToParentViewController])
{
int currentVCIndex = [self.navigationController.viewControllers indexOfObject:self.navigationController.topViewController];

ParentViewController *parent = (ParentViewController *)[self.navigationController.viewControllers objectAtIndex:currentVCIndex];

parent.dataArray = self.dataArray;
}


}

Any Ideas why not working?

L00ps
  • 113
  • 2
  • 9
  • why not holding a permanent reference to the parent view? Otherwise I recomand a protocol methode for a "callback" http://stackoverflow.com/questions/16584930/objective-c-accessing-methods-from-custom-cell/16585079#16585079 – geo May 25 '13 at 18:13

2 Answers2

0

It is working when using isMovingFromParentViewController instead of isMovingToParentViewController.

That doesn't make any sense to me at all.

danielbeard
  • 9,120
  • 3
  • 44
  • 58
L00ps
  • 113
  • 2
  • 9
0

Ok. It seems isMoving has nothing to do with the navigation stack at all. Even when using [self.navigationController isMovingToParentVC], it's only saying that it's moving, to whatever view.

danielbeard
  • 9,120
  • 3
  • 44
  • 58
L00ps
  • 113
  • 2
  • 9