unrecognized selector sent to instance XXXX 'NSInvalidArgumentException'

Discussion in 'iOS Programming' started by abohak, Aug 13, 2008.

  1. abohak macrumors newbie

    Joined:
    Aug 13, 2008
    #1
    Hello,

    I have many years of object oriented programming experience on the major platforms. I need to create an application for my iPhone G3. I've downloaded the development SDK and have successfully generated a few demo applications, so now I am working on my real applicatilon which is based upon the standard tabbed application project generation selection. There are 4 xib files: MainWindow, tabbed view A, tabbed view B, and the view that I want to transition to collect starting and ending times. I am using Interface Builder for designing my views.

    My application has a tabbed control bar with three buttons. When the middle tabbed control bar button is pressed, the correct view is displayed and on it is a button. When the button is pressed, I want to transition to another view so I can gather some information from the user and then return to the previous view. Right now, with all of the code commented out, when the button is pressed, a runtime exception is generated:

    "unrecognized selector sent to instance XXXX 'NSInvalidArgumentException', reason: [UIViewController handleStartEndTimeButton] unrecognized selector sent."

    - (IBAction) handleStartEndTimeButton:(id) sender

    {
    // StartEndTimeViewController *modalStartEndTimeViewController = [[[StartEndTimeViewController alloc]
    // initWithNibName: nil bundle:nil] autorelease];
    // UINavigationController *modalStartEndTimeNavigationController = [[UINavigationController alloc]
    // initWithRootViewController:modalStartEndTimeViewController];
    // [self.navigationController
    // presentModalViewController:modalStartEndTimeNavigationController animated:YES];
    }

    Interface Builder shows that the button is connected to my handler function.


    I have two questions:

    (1) What am I doing wrong with my handler function? Why is an exception generated when the button is pressed? I have three ViewController classes: AViewController, BViewController, and StartEndTimeViewController. BViewController is the one that has the button handler function in it. Do I need to create instances of these ViewController classes? In InterfaceBuilder, I told it which XIB to use with each tabbed button. My gut tells me that I need to create an instance of my ViewControllers somewhere, but where?

    (2) Okay, so let's say that we have resolved the issue in item #1. What code do I need to put into the handler function to create the view and show it? I have included what I think will work in the handler function that I showed earlier... Am I close?

    I REALLY, REALLY appreciate any guidance!

    Thanks!

    Mike [/SIZE][/FONT]
     
  2. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #2
    I think somehow your connection in IB is messed up. The error shows the selector as "[UIViewController handleStartEndTimeButton]" but you have it defined as handleStartEndTimeButton: - notice the semicolon? handleStartEndTimeButton is different from handleStartEndTimeButton:
     
  3. sujithkrishnan macrumors 6502

    Joined:
    May 9, 2008
    Location:
    Bangalore
    #3
    Can u tell the difference between both methods ???
    If different how can i call both differently????
     
  4. keehun macrumors regular

    Joined:
    Mar 17, 2008
    #4
    How do you have the header file set up? Can you post some of that?
     

Share This Page