bBcdd bBcdd - 4 months ago 104
iOS Question

Xcode 8 beta 6 unwind segue seems broken because "WithSegue" is added to @IBAction unwind method name automatically

I just realised that, in the current Xcode 8 beta 6, when I hook up an unwind action to, e.g., a bar button item in a modally presented view controller to unwind the modal presentation segue and present the view controller previously in the navigation stack, Xcode adds an "WithSegue" to the name of the existing @IBActions that can be used for this purpose - and that this breaks the unwind segue (it won't be performed). If I edit the storyboard file in source code (as XML), and remove this "WithSegue" from the @IBAction method identifier, the segue works as expected. For example, my unwind method in the originating view controller (the destination for the unwind segue) is called "unwindFromSettingsToTableView" - and Xcode/Interface Builder rename this method to "unwindFromSettingsToTableViewWithSegue" when I CTRL-connect the bar button item in the modally presented view controller to the view controller's exit item in the scene dock.

Is this a bug in Xcode 8 beta? Is it a known bug? Am I missing something?

I checked my previously connected unwind segues (connected in Xcode 7), and they don't have this "WithSegue" suffix. If I delete those existing "vintage" unwind segues, and connect them again in Xcode 8, Interface Builder now suggests the same method name with the "WithSegue" suffix - and those segues break. When I delete the suffix in storyboard source code, the unwind segue works again.

Would be great to get any indications. This behaviour is annoying.

Best wishes!

Rob Rob

In Swift 3, if you don't want it to add WithSegue, define your @IBAction method to not name the first parameter:

@IBAction func unwindHome(_ segue: UIStoryboardSegue) {
    // this is intentionally blank

If you don't use that _ syntax, when it goes to hook up the @IBAction, it will add the WithSegue to the name.

When I use the above syntax for my unwind action, it works fine in Xcode 8, beta 6.

As an aside, when I don't use the _ syntax shown above in beta 6, it names the action unwindHomeWithSegue but it still works with that longer name, with no editing of the storyboard XML needed. I wonder if your non-functioning unwind segue is a result of some other issue. We need a reproducible example of the problem to diagnose further. Perhaps you can share a MCVE.