Why unwind method doesn't work now in UIKit?

Hello everyone, I'm facing a problem that I can't connect the button to the unwind segue.

I have made a simple application with three controllers.

The unwind segue code is located in Table View Controller.

@IBAction func unwindToTableViewController(_ unwindSegue: UIStoryboardSegue) {
        let sourceViewController = unwindSegue.source
    }

A first segue has been implemented from the Add button on Table View Controller to the View controller. It is a Push type.

There is a Save button as Bar Button Item in the View Controller.

When I try to drag a connection from Save button to the Exit icon of the View Controller, the context menu does not open indicating the unwind segue. Instead, a context menu appears with different types of segues.

At the same time, if I just click the Exit icon, a context menu appears where the unwind method is visible.

Just in case, I re-read the documentation again and looked at examples of using the unwind method. There is no mention of this problem anywhere.

The only hypothesis left is that this problem is related to the new version of Xcode.

The example of application given here was created in XCode 15.3. I have tested the same application on another computer, where the version of Xcode is 13.4.1. There, when I try to drag a connection from the Save button to the Exit icon, a context menu appears with the name of the unwind method.

But the problem didn't end there because after the connection is established, the button does not work and the View Controller does not dismiss.

I can't understand why this is happens. It worked before. Is that one a bug or the feature?

How to fix it?

Any ideas would be greatly appreciated!

Replies

I found a solution to this issue.

It needs to right-click the Exit icon. Then, by the left-click, drag the connection from the circle of the unwind method to the button on the screen. And in another window that appears, click action.

And after clicking the button, a transition to the target view controller occurs, as well as data passing.

  • Fantastic. Develop in Swift Fundamentals Navigation and Workflows is wrong. Can't drag from the dismiss button to the exit. Right clicking and control dragging to the button does work. Thank you so much!

Add a Comment