Transition to a new View Controller in Swift 2.0 - ios

I previously transistioned from one VC to another by:
Creating a button
Ctrl-drag the button to the new VC
Select Custom
That was it and it worked. Now however, I am trying this again on a new app and I am getting the error : * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not perform segue with identifier '(null)'. A segue must either have a performHandler or it must override -perform.'
* First throw call stack:
Is there something I need to add since Swift2.0?

With custom segue type, u have to give it indentifier and custom handler, if not, choose show type if u have Navigation Controller or show modally type , that wont need to name or add anything else and it will just work
U can read more about custom segue here or here

Related

Segue Identifier is going missing in Swift 5.6

I've only been programming for a month, and I am trying to cobble together a mockup and I keep getting the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<OutsizeMockup_0_1.HomeViewController: 0x13460f870>) has no segue with identifier 'testSegue''
I get this when I have my segue transition:
self.performSegue(withIdentifier: "goToProducts", sender: self)
within my buttonWasPressed method(which is called after my URLSession is created), but not when I call it within any other button that's not nested in Session. So I know the identifier is spelled correctly and under the right view controller class. I'll post my code below.
My project layout
First the browse button is pressed and the fetchDrop method is called:
HomeViewController where button is pressed
Then, the class that manages the url session is called: DropManager class with url session. Using this data, pM.initializeProducts is called, leading to the next file
Finally, buttonIsPressed is called here. And once it's called, the segue within the HomeViewController gets the error that I mentioned above
I'd be interested to know if there are any glaring issues with my code.

Receiver has no segue with identifier in self.performSegue(withIdentifier, sender)

I'm getting this follow message when I try open a table item in my 'add' form to update it.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver () has no segue with identifier 'verBeneficioSegue''
Github with project: https://github.com/felipeejunges/MyBenefits
Segue:
My code:
When I was debbuging I got error in line 58.
P.S. I'm doing a project exercise for my post-degree in iOS.
I try to clean up project, restart Xcode, restart my Mac, but nothing worked.
From the crash the segue is inside vc named ListarBeneficiosTableViewController
ListarBeneficiosTableViewController: 0x7fbf6d510340>) has
no segue with identifier 'verBeneficioSegue'
and your vc shown in picture is named MyBeneficio ( it's a UITaBarController ) which isn't the same hence the crash
If your purpose is to add another tab to the tabs controller you should drag the segue from the tab to the listoVC and select viewControllers from the popup
Otherwise the segue origin should be ListarBeneficiosTableViewController and it's destination is another vc
You are saying
self.performSegue(withIdentifier: "verBeneficio", sender: beneficio)
in your ListarBeneficiosTableViewController class. This implies that your ListarBeneficiosTableViewController instance is loaded from the storyboard and in the storyboard it has a segue called "verBeneficio".
Okay, so let's look in the storyboard. When we do, we see that the "verBeneficio" segue does not come from the ListarBeneficiosTableViewController. It comes from the tab view controller.

Receiver has no segue with identifier, though the segue is actually declared

I'm working in a new Swift project, where I'm trying the simple task of executing a segue whenever a button is pressed. However, whenever I try to trigger the segue, the following error pops up:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<Ma2Mi.LandingViewController: 0x7f99c65122b0>) has no segue with identifier 'showLogin''
Relatively simple, except for that there's actually a segue named showLogin:
(the top view controller is of type LandingViewController.)
This is how the segue is invoked:
loginButton.addAction {
self.performSegue(withIdentifier: "showLogin", sender: nil)
}
How is it possible that such a simple task is failing? Perhaps a bug, or something I overlooked?
Thanks.
Did you use the required init() function on the ViewController triggering the segue? I had the same issue until I removed it.

'Receiver has no segue with identifier' when identifier exists

For an iOS app, I have a story board and multiple controllers, and a segue going from controller GameClass to controller SettingsClass. The segue, in view Controller GameClass has an identifier called GameToSettings:
However, when I want to call the segue from my GameClass:
[self performSegueWithIdentifier: #"GameToSettings" sender: self];
I get the error message
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<GameClass: 0xcf0c550>) has no segue with identifier 'GameToSettings''
I tried many tips I found in other articles (like renaming the storyboard, cleaning the project, changing simulator format, giving another name to the segue, ), but the issue keeps coming.
I've uploaded a version of my code here: http://www.petits-suisses.ch/Issue.zip.
Any suggestion of what I could continue trying ?Thanks.
You should not instantiate your view controller this way:
GameClass *myNewVC = [[GameClass alloc] init];
Instead, use
[[UIStoryboard storyboardWithName:#"storyboard name" bundle:nil] instantiateViewControllerWithIdentifier:#"vc identifier">]
Edit:
Take a look at https://github.com/mac-cain13/R.swift
It will allow you to instantiate it easily with autocompletion, type safe method: R.storyboard.main.myViewController

segue button to next viewcontroller throws error in xcode

I have a tabbar ios application. I put (embed) NavigationController in one of the viewcontroller,then added one button and one new viewcontroller to pass. I dragged from button in first vc to new vc and select "push".
But following error message is thrown when I tab the button :
Terminating app due to uncaught exception 'NSGenericException', reason: 'Push segues can only be used when the source controller is managed by an instance of UINavigationController.'
I really don't understand because I have already a navigation controller and also not added any additional code yet.
Thanks for any help.
You may not use push segue with a button that you have created yourself. Try using Modal segue instead.

Resources