swiftuiviewcontrollerstoryboard

Can you have two Segues from different View Controllers going to one View Controller Swift 3


I am currently trying to send myslideMenuVC to my ProfileVC upon tapping a cell. I go to instantiate the ProfileVC with a storyboard identifier, but I already have a segue to this view controller from my LoginVC. Are you allowed to have 2 segues on one view controller? If yes, why won't this this segue work, because I am receiving this error:

terminating with uncaught exception of type NSException, Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard (<UIStoryboard: 0x618000a78400>) doesn't contain a view controller with identifier 'profileFromSlideMenu''

 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        //self.selectedPost(index: 0)
        if indexPath.row == 0 {
            if let myProfileVC = self.storyboard!.instantiateViewController(withIdentifier: "profileFromSlideMenu") as? Profile {
            self.present(myProfileVC, animated: true, completion: nil)
            }
        }
        if indexPath.row == 1 {
            handleLogout(Any.self)
            
        }
    }

Solution

  • Yes, you are allowed to have several segues going from different View controllers to a single View controller.

    The problem is you have either not set up an identifier for that particular view controller or you have a typo in the identifier in your code.