Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Segue not calling prepareForSegue

Perhaps I am missing something simple. I added a modal segue from a button to a view controller. I then added some steps to prepareForSegue (and checked I had named the segue correctly). I have done this a few other times with no problem.

Now, when I click the button, the modal window opens, but the prepareForSegue does not fire. I tried putting a log statement in the prepareForSegue before it even checks the description of the label (so theoretically it should fire for any segue). But I get nothing logged.

Any ideas?

like image 761
Ben Packard Avatar asked Jan 22 '12 06:01

Ben Packard


2 Answers

Connecting a segue from a button to the next controller is the correct way to connect it, just remember that prepareForSegue: is called on the VC that owns the button not the incoming controller. You get the incoming controller by calling [segue destinationViewController].

like image 121
theMikeSwan Avatar answered Oct 09 '22 09:10

theMikeSwan


Well I found the rookie error I suspected. I duplicated a VC and forgot to set it's class to my new VC class.

like image 9
Ben Packard Avatar answered Oct 09 '22 07:10

Ben Packard