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

kashmoney2006

macrumors regular
Original poster
Dec 12, 2007
232
0
I have set up a NSTextfield object and NSButton object and placed both of them on the application window using Interface Builder. I then connected the text field to text00 and the button to setText:

here is my code:
Code:
@interface TicTacToeController : NSObject {
	
	IBOutlet NSTextField *text00;

}

- (IBAction)setText: (id)sender;

and
Code:
@implementation TicTacToeController

- (IBAction)setText: (id)sender {
	
	[text00 setStringValue:@"X"];

}

what i am trying to do is, have the text field display an X when the button is pushed. but, when i run the program in the simulator in IB and push the button, nothing happens. can anybody help me out? all input is appreciated. Thanks.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
You can use NSLog() for some simple debugging (which shows up in the Run > Console window):

Code:
- (void)awakeFromNib {
    NSLog(@"text00: %@", text00);
}

- (IBAction)setText: (id)sender {
    NSLog(@"sender: %@", sender);
    [text00 setStringValue:@"X"];
}

If you see "(null)" for text00, then that means text00 isn't properly connected in IB. If you don't see the "sender" log, then that means your button's IBAction isn't properly connected.
 

kashmoney2006

macrumors regular
Original poster
Dec 12, 2007
232
0
You can use NSLog() for some simple debugging (which shows up in the Run > Console window):

Code:
- (void)awakeFromNib {
    NSLog(@"text00: %@", text00);
}

- (IBAction)setText: (id)sender {
    NSLog(@"sender: %@", sender);
    [text00 setStringValue:@"X"];
}

If you see "(null)" for text00, then that means text00 isn't properly connected in IB. If you don't see the "sender" log, then that means your button's IBAction isn't properly connected.

Thanks. I got it to work. Is there any way to set up the console to pop up everytime I run the app? or do i have to keep going to Run->Console to bring up the console window
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
It should stay open once it's open, and even re-open when you open the project if it was open when you closed the project.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.