@interface TestViewController : NSViewController
@property (nonatomic, retain) IBOutlet NSTextField *myLabel;
- (IBAction)sendMessage:(NSButton *)sender;
@end
@implementation TestViewController
@synthesize myLabel = _myLabel;
- (id)init{
self = [super init];
if(self){
[self updateLabel];
}
return self;
}
- (IBAction)sendMessage:(NSButton *)sender {
[self updateLabel];
NSLog(@"Message sent");
}
- (void) updateLabel{
NSLog(@"Update!! %@");
[self.myLabel setStringValue:@"random text"];
}
@end
I want to update an NSTextField when view is displayed, and i put my updateLabel
at init
in the log i see Update!!
but the NSTextField
it's not update with my text.
But when i press the button that calls the same updateLabel
the NSTextField
is updatet. Can someone help me to understand why it's not working as expected ?