IBAction not being seen by xcode

Discussion in 'iOS Programming' started by macdude3, Jun 19, 2010.

  1. macdude3 macrumors member

    Jun 16, 2010
    So I have an IBAction called buttonPressed. I put it in my header as
    and I put it into my main as the same thing
    However, when I go to IB and try to hook things up I do not get a buttonPressed connection ability. Why doesn't it give me one?
  2. chown33 macrumors 604

    Aug 9, 2009
    Note the :.
  3. macdude3 thread starter macrumors member

    Jun 16, 2010
    thanks!! That fixed it. However now I go into the app, press the button and the app quits out. What does that mean? Is there some way I can see why it is quitting out?
  4. chown33 macrumors 604

    Aug 9, 2009
    It could mean anything. You haven't posted any code, and you haven't said whether you've tried using a debugger.

    Nobody here is psychic, so you have to provide more info than "it quits".
  5. macdude3 thread starter macrumors member

    Jun 16, 2010
    Alright so I tried using the debugger once. When I press my button it quits and in the lower left of the screen it says "GDB: Interrupted"

    When I run it in the console it gives me this:

    2010-06-20 00:31:52.774 HelloWorld003[4464:207] *** -[HelloWorld003ViewController buttonPressed:]: unrecognized selector sent to instance 0x391ef60
    2010-06-20 00:31:52.776 HelloWorld003[4464:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[HelloWorld003ViewController buttonPressed:]: unrecognized selector sent to instance 0x391ef60'
    2010-06-20 00:31:52.778 HelloWorld003[4464:207]

    Here is the header:
    #import <UIKit/UIKit.h>
    @interface HelloWorld003ViewController : UIViewController {
    	IBOutlet UIImageView *uiImageView;
    	IBOutlet UILabel *label;
    @property (nonatomic, retain) IBOutlet UIImageView *uiImageView;
    @property (nonatomic, retain) IBOutlet UILabel *label;
    - (IBAction)buttonPressed:(id)sender;
    Here is the changed part of the main, there are things below it, but I never touched any of it:
    #import "HelloWorld003ViewController.h"
    @implementation HelloWorld003ViewController
    @synthesize label, uiImageView;
    - (IBAction)ButtonPressed: (id)sender{
    	label.text = @"Hello World I'm Back!";
    	UIImage *imageSource = [UIImage imageNamed:@"icon.png"];
    	uiImageView.image = imageSource;
    I was able to connect everything together in File's Owner just fine and I am getting no errors. Just warnings of
    " method definition for '-buttonPressed:' not found" and
    " incomplete implementation of class 'HelloWorld003ViewController'"

    Thanks for any help. I hope I can get it to work.
  6. kainjow Moderator emeritus


    Jun 15, 2000
    Obj-C is case-sensitive. ButtonPressed != buttonPressed
  7. chown33 macrumors 604

    Aug 9, 2009
    Those two warnings are extremely important, and your program will not work until they are fixed.

    You should immediately enable the build option Treat Warnings As Errors (enter the words treat warnings in the build settings search box). The default for this setting is disabled, which is more appropriate for experienced developers. Beginners often need the added discipline, especially if their default response to warnings is to ignore them.

    If you're not going to enable the build setting, then you must change the way you deal with warnings. Do Not Ignore Any Warning.

    The reason it's only a warning is because it's not actually a compile-time error. Objective-C as a language has certain things it can never determine at compile-time, only at run-time. For those, the compiler emits warnings, not errors. The compiler itself has no way to tell if you are an experienced developer or a beginner.

    I also want to commend you for post #5. It is a fine example of how to ask a question that can be answered without a lot of back and forth.

    You gave the console output messages, which provides information about what actually caused the program's failure.

    You gave the source code for the area that was causing the problem.

    You gave the compiler's error and warning messages, which helps narrow down where to look in the source.

Share This Page