Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

16
  • 6
    This solution works really great on iOS 14 and it is quite elegant. I would recommend to use a switch instead if (now is allowed), specially if there is more than two views to make it cleaner Commented Aug 22, 2020 at 10:11
  • 1
    @jarnaez you're totally right! it works from now on! thank you, I updated the answer and my project as well :) Commented Aug 22, 2020 at 19:12
  • 1
    I love this solution - but for two things....1) couldn't make it work with a switch, it was much happier with a series of ifs. 2) And do you dismiss a sheet programmatically? In the traditional approach with a single sheet you toggle the isPresented flag, that's not here. Thank you. Commented Sep 12, 2020 at 23:51
  • 2
    @TobiasTimpe you can pass a closure, that sets activeSheet to nil (e.g. SheetToShow(onCompleteBlock: { self.activeSheet = nil }) and then just call that closure from the sheet). You could also pass activeSheet to the sheet and set it to nil inside the sheet, but I would recommend against exposing this parameter to other views Commented Sep 16, 2020 at 13:54
  • 1
    @Marcio yes it does, but as I said it’s not optimal - to expose the property. Better pass the closure, that will change it. It’s better testable and less error-prone Commented Sep 17, 2020 at 15:30