I'm facing the error message:
"UIStoryboardSegue does not have a member named 'identifier'"
Here's the code causing the error
if (segue.identifier == "Load View") { // pass data to next view }
On Obj-C it's fine using like this:
if ([segue.identifier isEqualToString:@"Load View"]) { // pass data to next view }
What am I doing wrong?
The segue object contains information about the transition, including references to both view controllers that are involved. Because segues can be triggered from multiple sources, you can use the information in the segue and sender parameters to disambiguate between different logical paths in your app.
Swift version: 5.6. Segues are a visual way to connect various components on your storyboard, but sometimes it's important to be able to trigger them programmatically as well as after a user interaction.
You create the unwind segue as per usual - drag to the exit icon in the scene. Now in the object inspector on the left you will see the unwind segue listed below the view controller, first responder and exit icons. You can click on the unwind segue and give it an identifier in the inspector on the right.
This seems to be due to a problem in the UITableViewController
subclass template. It comes with a version of the prepareForSegue
method that would require you to unwrap the segue.
Replace your current prepareForSegue
function with:
override func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) { if (segue.identifier == "Load View") { // pass data to next view } }
This version implicitly unwraps the parameters, so you should be fine.
Swift 4, Swift 3
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if segue.identifier == "MySegueId" { if let nextViewController = segue.destination as? NextViewController { nextViewController.valueOfxyz = "XYZ" //Or pass any values nextViewController.valueOf123 = 123 } } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With