jpdery/moobile-core — pull request #14 by imbibinebe (2013-04-03 10:46:57+00:00)
Title: Ease communication between view controllers ?

In a view controller, it is not uncommon that we want to retrieve data/variables from the view controller it was pushed from. However, it is not that easy to do so by using ViewControllerStack.

exemple:
VC1 pushes VC2 (VCS = [VC1 VC2])

In its viewWillEnter method, VC2 gets data from a server depending on a VC1 variable. To achieve this, it can do the following to get VC1:
this.getViewControllerStack().getChildViewControllers().getLastItemAtOffset(1) returns VC1

then, VC2 pushes VC3 (VCS = [VC1 VC2 VC3])
VC3 do some stuff and pops back to VC2.
In its viewWillEnter VC2 tries again to get data from a server depending on a VC1 variable. However, VCS is still equal to [VC1 VC2 VC3] and then
this.getViewControllerStack().getChildViewControllers().getLastItemAtOffset(1) returns VC2 itself ... we have a problem :)

That's why i suggest you these modifications:

If VC[i] needs to access VC[i-1] it has just to call this.getPusher(), whatever the method it is called from (viewDidLoad, viewWillEnter, viewDidEnter ...)

If VC[i] needs to acces VC[i-2] it has just to call this.getPusher().getPusher() and so on.

What do you think ?