I'm struggling the whole day to fix "has no segue with identifier" error and got stuck.
Error message:
SegueTest[41862:1585831] *** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Receiver (<SegueTest.TableViewController: 0x7feed6510260>) has no segue with identifier 'tableToCollectionSegue''
*** First throw call stack:
Related files getting error:
Please check my Main.storyboard
on GitHub.
Capture of segue configuration for ViewController (👌 Working)
Capture of segue configuration for TableViewController (❌ Getting error)
Environment:
What I did in Main.storyboard:
Created UINavigationController
as an initial view controller and connect to RootViewController
as a root view controller
Create UINavigationController
that opened from RootViewController
as a modal view
Connected the Open Modal
button with the modal UINavigationController
and named it navigationSegue
Create ViewController
, TableViewController
, and CollectionViewController
Connect the modal UINavigationController
with the ViewController
as a root view controller
Connect the ViewController
with the TableViewController
as a triggered segue (manual) named viewToTableSegue
Connect the TableViewController
with the CollectionViewController
as a triggered segue (manual) named tableToCollectionSegue
Connect the the Next
Button on the ViewController
with @IBAction func didTapNext(_ sender: Any)
declared in ViewController.swift
How the error occurs:
When I called performSegue(withIdentifier:sender:)
in ViewController.swift
, it works.
(Segue capture)
// Go to TableViewController
@IBAction func didTapNext(_ sender: Any) {
// 👌 Working
self.performSegue(withIdentifier: "viewToTableSegue", sender: nil)
}
When I called performSegue(withIdentifier:sender:)
in TableViewController.swift
, it got the error.
(Segue capture)
override func tableView(_ tableView: UITableView,
didSelectRowAt indexPath: IndexPath) {
self.tableView.deselectRow(at: indexPath, animated: true)
// ❌ The segue `tableToCollectionSegue` is connected
// from `TableViewController` to `UICollectionViewController`,
// but got error.
//
// *** Terminating app due to uncaught exception 'NSInvalidArgumentException',
// reason: 'Receiver (<SegueTest.TableViewController: 0x7feeea04a090>) has no segue with identifier 'tableToCollectionSegue''
self.performSegue(withIdentifier: "tableToCollectionSegue", sender: nil)
// ❌ The segue `tableToCollectionSegue` is not connected
// from `UINavigationController` to `UICollectionViewController`.
// This error is expected.
//
// *** Terminating app due to uncaught exception 'NSInvalidArgumentException',
// reason: 'Receiver (<SegueTest.TableViewController: 0x7feeea04a090>) has no segue with identifier 'tableToCollectionSegue''
// self.navigationController?.performSegue(withIdentifier: "tableToCollectionSegue", sender: self)
}
What I have read:
What I have tried:
~/Library/Developer/Xcode/DerivedData/
directoryRemove the following lines from TableViewController
:
required public init?(coder aDecoder: NSCoder) {
super.init(style: .plain)
}