Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

macdude3

macrumors member
Original poster
So I have an IBAction called buttonPressed. I put it in my header as
Code:
 -(IBAction)buttonPressed(id)sender;
and I put it into my main as the same thing
Code:
 -(IBAction)buttonPressed(id)sender;

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?
 
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?
 
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".
 
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:
Code:
#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;


@end

Here is the changed part of the main, there are things below it, but I never touched any of it:
Code:
#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.
 
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'"

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.

EDIT:
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.