Hersh Bhargava Hersh Bhargava - 6 months ago 17
iOS Question

Storyboard thinks Segue does not Exist. But it does

I have a show segue between two ViewControllers in my Storyboard. When call

performSegueWithIdentifier:
, I get an
NSInvalidArgumentException
:

Receiver (<[MY VIEWCONTROLLER SUBCLASS]: 0x7fc9e99f0640>) has no segue with identifier 'HomeToSettings''


The segue definitely exists and is connected, and there are many other segues on the same origin ViewController that work fine.

In the source code for the storyboard, the segue shows up just like all the working ones:

<connections>
<outlet property="notificationsButton" destination="hG9-8E-sv6" id="mn0-1x-Qxj"/>
<outlet property="settingsButton" destination="Fy0-au-d6J" id="r1c-fG-KOP"/>
<outlet property="tableView" destination="9bJ-Cd-hc3" id="Wuy-hJ-QVU"/>
<segue destination="ad8-yH-D5h" kind="show" identifier="HomeToCreateList" id="bsg-J2-Gp3"/>
//More segues...
<segue destination="pNX-Jw-wau" kind="show" identifier="HomeToNotifications" id="B2t-BE-YpW"/>
<segue destination="xge-ah-WXM" kind="show" identifier="HomeToSettings" id="nTa-qO-SCb"/>
</connections>


I have tried:


  • Renaming the storyboard

  • Deleting and recreating the segue

  • Renaming the segue

  • Cleaning the project

  • Reinstalling the app

  • Reset content and settings on the simulator

  • Physical device



Xcode and iOS are up to date as of June 1, 2016.

If it's somehow important, I am triggering the segue through an IBAction attached to a UIBarButtonItem. However, another segue to a different ViewController from another UIBarButtonItem works perfectly.

The exact line with which I'm calling the segue is:

[self performSegueWithIdentifier:@"HomeToSettings" sender:self];


I'm really lost here.

Answer

For example you have show segue named HomeToSettings from VC-A to VC-B then you only can call [self performSegueWithIdentifier:@"HomeToSettings" sender:self]; only from VC-A.

If you tried to call from other controller then it will give error.

I just copied your statement [self performSegueWithIdentifier:@"HomeToSettings" sender:self]; and I found one weird character before H of your HomeToSettings string.

You can check it by left arrow key of keyboard or back space!!

Character looks like

enter image description here

So,remove it from everywhere where you set this identifier.

Copy identifier from below statement and use it to set in interface builder and use below statement to perform segue.

  [self performSegueWithIdentifier:@"HomeToSettings" sender:self];

Hope this will help :)

Comments