0

I am struggling with this problem for a few hours now. I have a view with a tableView and custom cell in it. What I am trying to do is to perform a segue which is in my viewController from the custom cell. The first thing I did was to create a variable called "parent" in my cell.swift with the type "viewController".

weak var parent : ViewController!

After that, I'm just trying to perform the segue like this :

parent.performSegueWithIdentifier("eventDetails", sender: parent)

And I have the following error : Receiver (<Deevent.ViewController: 0x7fb99074f5d0>) has no segue with identifier 'eventDetails'

So I tried something else... I created a button in my ViewController and connected a segue to the next view (everything from the storyboard file)

In my viewController.swift I created the following function

func viewEventDetails() {
    performSegueWithIdentifier("eventDetails", sender: self)
}

and this one in my cell.swift :

func viewEvent(sender: AnyObject) {
    parent.viewEventDetails()
}

So when I call it from the cell, it crashes with the same error than before but when I click on the button it's working. I even tried to click on the button programmatically btnDetails.sendActionsForControlEvents(UIControlEvents.TouchUpInside) and I had the exact same error.

I've already tried to clean my project and delete it from the simulator. I'm really missing something here... hope somebody can help me.

Thanks !

Nicolas Meienberger
  • 777
  • 2
  • 8
  • 18

1 Answers1

0

It sounds like you need to give your segue an Identifier.

A view controller can have multiple segues, and so you need to define which one you want to use. In your case, in your code you are using the Identifier "eventDetails".

Assuming you are using a Storyboard, you need to click on the segue arrow between the two view controllers, and in the Attributes Inspector on the right, set the Identifier value to "eventDetails".

JoGoFo
  • 1,928
  • 14
  • 31