Question

I am having an unrecognized selector sent to instance issue. I know which line I am having problem with, but I don't understand why it doesn't recognize it. (I tested this code in when I was creating my container views and it works just fine. But for some reason when I merge it to my main project I am getting this error.)

This is my console output:

2013-12-20 16:47:59.633[8545:70b] -[UIViewController decideViewController:]: unrecognized selector sent to instance 0x8b5c250
2013-12-20 16:47:59.659[8545:70b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController decideViewController:]: unrecognized selector sent to instance 0x8b5c250'
*** First throw call stack:
(
    0   CoreFoundation                      0x01c075e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x0198a8b6 objc_exception_throw + 44
    2   CoreFoundation                      0x01ca4903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
    3   CoreFoundation                      0x01bf790b ___forwarding___ + 1019
    4   CoreFoundation                      0x01bf74ee _CF_forwarding_prep_0 + 14
    5   TProduct                          0x0000566f -[GameViewController changeViews:] + 143
    6   TProduct                          0x00005404 -[GameViewController timerTick:] + 532
    7   Foundation                          0x015c1927 __NSFireTimer + 97
    8   CoreFoundation                      0x01bc5bd6 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
    9   CoreFoundation                      0x01bc55bd __CFRunLoopDoTimer + 1181
    10  CoreFoundation                      0x01bad628 __CFRunLoopRun + 1816
    11  CoreFoundation                      0x01bacac3 CFRunLoopRunSpecific + 467
    12  CoreFoundation                      0x01bac8db CFRunLoopRunInMode + 123
    13  GraphicsServices                    0x0387b9e2 GSEventRunModal + 192
    14  GraphicsServices                    0x0387b809 GSEventRun + 104
    15  UIKit                               0x006f8d3b UIApplicationMain + 1225
    16  TProduct                          0x000070fd main + 141
    17  libdyld.dylib                       0x0224570d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

and this is the part that it doesn't recognize GameViewController.m

-(void)changeViews:(NSString *)gameStateSegueIdentifier
{
    NSLog(@"show view gameStateSegueIdentifier :%@",gameStateSegueIdentifier);
    [self.containerController decideViewController:gameStateSegueIdentifier];
}

and this is the method I am calling ContainerViewController.m

-(void)decideViewController:(NSString *)gameStateSegueIdentifier
{
    if (gameStateSegueIdentifier == _currentSegueIdentifier) {
        return;
    }

    while (gameStateSegueIdentifier != _currentSegueIdentifier) {
        NSLog(@"this is the gameStateSegueIdentifier %@",gameStateSegueIdentifier);
        NSLog(@"this is the currentSegueIdentifier %@",_currentSegueIdentifier);

        [self changeViewControllers];
    }
}

I understand that there are lots of "unrecognized selector sent to instance" questions already. But so far, I wasn't able to find an answer for my case. I appreciate the help.

Was it helpful?

Solution

The error message you're getting explains the problem:

2013-12-20 16:47:59.633[8545:70b] -[UIViewController decideViewController:]: unrecognized selector sent to instance 0x8b5c250

This is telling you that an instance of the class UIViewController got the message decideViewController:. UIViewController does not respond to this message. So, it seems that self.containerController is a UIViewController rather than a ContainerViewController. (If it was a ContainerViewController, it would say so in the error message.)

The fact that the property is declared as a ContainerViewController doesn't mean that there's actually a ContainerViewController in it. Go to where you actually create this object and assign it to that property, and ensure you're creating it as the correct class.

OTHER TIPS

when the selector is not recognized you don't need to show the code for the selector, because it is not executed.

Show the property line of containerController.

  1. Are you 100% sure that self.containerController is a ContainerViewController, your error message shows a UIViewController, so you are doing something special like cluster or a category?

  2. Are you using #import "ContainerViewController"?

  3. Is the method in the @implementation @end part?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top