Difference between unwind segue and delegation

橙三吉。 提交于 2019-12-05 13:18:19

Using an unwind segue is very similar to having a delegate, with the following advantages:

  • You don't need to implement any dismiss logic
  • You don't need to pass references up and down the navigation stack
  • You don't need to declare a delegate protocol
  • It's trivial to unwind back a number of stages in your app

The disadvantages are

  • Dependent on using storyboards (which may hamper reusability)
  • If there are a lot of them, it can lead to the same messiness as you can get in prepareForSegue with a lot of branching off identifier names
  • If you decide to present the view controller via some other method (not a segue) then you can't unwind back from it

The code you have looks good. I'd stick with it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!