1.11M Members

The label won't change when I press the button.

 
0
 

Everytime I press the button, it's supposed to change the label, but it doesn't. It also doesn't see that I have made any connections. Please help. Thank you in advance.

AppController.m:

#import "AppController.h"

@implementation AppController

-(IBAction)sayHello:(id)sender{
    [label setStringValue:@"Hello World!"];
}

@end

AppController.h:

#import <Foundation/Foundation.h>

@interface AppController : NSObject{
    IBOutlet NSTextField *label;
}

-(IBAction)sayHello:(id)sender;

@end

The window:

Click Here

 
0
 

That is not a label that is a text field. Drag a label across from the object library, it will have type of UILabel. If you are using the latest version of xcode you should be putting an underscore on the front when referrring to them locally,

[_label setText=@"Hello World"];

or

self.label.text = @"Hello World";
 
0
 

That is not a label that is a text field. Drag a label across from the object library, it will have type of UILabel. If you are using the latest version of xcode you should be putting an underscore on the front when referrring to them locally,

Thank you, but I figured out what was wrong, coincidentally, today. All that was wrong was I had never set AppController.m in the Compile Sources. Thanks though.

Question Answered as of 1 Year Ago by ChrisPadgham
You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article