Izzy
Izzy

Reputation: 192

"unrecognized selector sent to instance" error during performSegueWithIdentifier, using SWRevealViewController

I'm new to iOS development and I'm implementing a slide-out menu, using the well-known SWRevealViewController by John Lluch. I'm following this video tutorial:

https://www.youtube.com/watch?v=5SUV1YY2yxQ

So far I have this storyboard:

enter image description here

The initial scene (Reveal View Controller) is trying to automatically trigger the 1st two segues (to the Table View and Navigation Controller).

When I build the app, I get the following error:

[SWRevealViewController initWithIdentifier:source:destination:]: unrecognized selector sent to instance 0x7d96f000

This error occurs on the line I've indicated below, in the 'loadStoryboardControllers' method, in SWRevealViewController.m (which is the class of my initial 'RevealViewController' scene on the storyboard)

- (void)loadStoryboardControllers
{
    if ( self.storyboard && _rearViewController == nil )
    {
        //Try each segue separately so it doesn't break prematurely if either Rear or Right views are not used.
        @try
        {
            //**ERROR OCCURS ON FOLLOWING LINE**
            [self performSegueWithIdentifier:SWSegueRearIdentifier sender:nil];
        }
        @catch(NSException *exception) {}

        @try
        {
            //**ANOTHER ALMOST IDENTICAL ERROR OCCURS ON FOLLOWING LINE**
            [self performSegueWithIdentifier:SWSegueFrontIdentifier sender:nil];
        }
        @catch(NSException *exception) {}

        @try
        {
            [self performSegueWithIdentifier:SWSegueRightIdentifier sender:nil];
        }
        @catch(NSException *exception) {}
    }
}

When the error occurs, the value of 'SWSegueRearIdentifier' is @"sw_rear", which is correct. This is the identifier I've given to the segue. The way that the SWRevealViewController is meant to work is that it looks first for the segue identified as "sw_rear" in order to automatically trigger it.

What could be causing the error, or what could I do to debug further?

Upvotes: 0

Views: 1372

Answers (1)

Paulw11
Paulw11

Reputation: 114975

initWithIdentifier:source:destination: is a method implemented by the UIStoryboardSegue class. It is invoked during the segue operation.

In this case it is being invoked against a UIViewController subclass, resulting in the exception.

In InterfaceBuilder make sure that the customclass for the Segue is a valid UIStoryboardSegue subclass - in the case of SWRevealController it should be SWRevealViewControllerSegueSetController

Upvotes: 4

Related Questions