Start New Discussion within our Software Development Community

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

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";

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.

This question has already been answered. Start a new discussion instead.