Search code examples
iosobjective-cstoryboardsegue

get sender of segue in destination view controller


I have a VC named Dashboard (D) which can open a VC named Login (L) and a VC named Register (R). Login can open VC Register too.

I try to use storyboard as often as possible, so I have created with it three Segues, D to L, D to R, L to R

So, in case of D -> L -> R and in case of D -> R, when I close R, I have to close L if it necessary and inform D which he can begin to load the user infos (launch function in nutshell).

So, I would like get the sender of Segue in destination vc, knowing that I put it in sender entrie of performSegueWithIdentifier like that :

[self performSegueWithIdentifier:@"SegueToFbRegister" sender:self];

Solution

  • I'd do this by having R send a notification when the registration/login is done, and having D listen to it then pop everything and load your data.

    If however you insist on getting a reference to the sender, you can add this property on your destination VC and set it in the source VC's prepareForSegue:sender: