Chapter 25: Difference between unwind segue and delegate protocol

Hello @fahim, it is great that you describe different approaches for the similar thing in iOS Apprentice book. I have Googled it but still not sure when use unwind segue and when have to delegate protocol. It seems to me that unwind segue is much easier. When I can’t use unwind segue and have to use delegate protocol?

@fahim Can you please help with this when you get a chance? Thank you - much appreciated! :]

The unwind segue will take you back to a view in your view hierarchy, but the method simply takes a storyboard segue as the parameter. So this is good for when you want to move back to a previous view and/or take an action where no data needs to be passed from your current view controller to the new view controller.

But what if you wanted to go back to a previous view and also pass some data (perhaps a change made in the current view controller) back? Then the unwind segue might not work as well and a delegate method might work better.

On the other hand, there are several other ways you can handle this too - notifications and closures would be two that come to mind immediately. So there’s usually many different ways to handle a given scenario. How you do it might just be a matter of preference issue :slight_smile:

This topic was automatically closed after 166 days. New replies are no longer allowed.