Unwind segues involve a run-time process that navigates from the current view controller, back up the chain of preceding view controllers, looking for the first instance it encounters that has an unwind action of the appropriate name. This means that it unwinds to the most recent occurrence.
So, if you go from view controller A
to B
to C
, and A
and B
have an unwind segue of the same name, when you unwind from C
using the unwind segue of that name, it will unwind to B
, the most recent one, not A
.
The run-time process of walking up the chain of view controllers is outlined in WWDC 2012 video Adopting Storyboards in Your App.
The above begs the question of the best choice for unwind action names. It's easy to jump to the conclusion of "just use unique unwind action names", but I think it's more complicated than that. Whether you use unique unwind action names or common/shared action names is just a question of the intent of the unwind action.
For example, sometimes you want to unwind all the way back to a particular scene. In that case you'd use some unique unwind action name. So, in our A
» B
» C
example, A
might implement unwindToA
and B
might implement unwindToB
.
But consider some flow by which the user could possibly navigate from A
» B
» D
or alternatively A
» C
» D
and you want D
to unwind to either B
or C
, as appropriate. In that case, B
and C
might implement a unwindFromD
action.
I suspect it was the desire for this sort of flexibility that prompted Apple to implement this sort of "walk up the chain of view controllers" run-time process rather than a "look for view controller of particular class" sort of approach.
Regardless, the choice of unique vs shared unwind action names simply depends your particular use-case.