Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSInvalidArgumentException

I'm getting a crash from this routine after adding the :(id)sender so I could determine which button called it. When set up as plain old toggleView3 it works perfectly. The crash occurs when detailView is toggled back to docView.

'NSInvalidArgumentException', reason: '*** -[RootViewController toggleView3]: unrecognized selector sent to instance 0x524a00' 2009-04-07 12:29:44.421 eTarot[11405:20b] Stack:

-(IBAction)toggleView3:(id)sender{


    if (detailViewController == nil) {
        [self loadDetailViewController];
    }

    UIView *docView = docViewController.view;
    UIView *detailView = detailViewController.view;

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:1];
    [UIView setAnimationTransition:([docView superview] ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft) forView:self.view cache:YES];

    if ([docView superview] != nil) {
        [detailViewController viewWillAppear:YES];
        [docViewController viewWillDisappear:YES];
        [docView removeFromSuperview];

        [self.view addSubview:detailView];
        [self.view insertSubview:detailNavigationBar aboveSubview:detailView];
        [docViewController viewDidDisappear:YES];
        [detailViewController viewDidAppear:YES];

    } else {
        [docViewController viewWillAppear:YES];
        [detailViewController viewWillDisappear:YES];
        [detailView removeFromSuperview];
        [detailNavigationBar removeFromSuperview];
        [self.view addSubview:docView];
        [detailViewController viewDidDisappear:YES];
        [docViewController viewDidAppear:YES];
    }
    [UIView commitAnimations];
}
like image 239
Alan Avatar asked Apr 07 '09 17:04

Alan


2 Answers

You're sending a view the message toggleView3 when the correct name of the selector is toggleView3: — that is, with a colon and argument. They may look similar to you, but they're totally different methods to Objective-C.

like image 72
Chuck Avatar answered Oct 17 '22 15:10

Chuck


That exception means your application is calling toggleView3 without the :sender argument somewhere. Since your new method requires an argument, it's the same as calling a method that never existed.

If you look through the stack trace in the debugger it should be pretty clear where it's coming from. There's probably a warning in the build results, too.

like image 33
Marc Charbonneau Avatar answered Oct 17 '22 17:10

Marc Charbonneau