I'm trying to change a label from the AppDelegate
. I can change the label with an IBAction
that runs a changeLabel
in the implementation of the class that has the label, but if I try to run changeLabel
from the AppDelegate
it changes the value (I have an NSLog), but doesn't update label.
Here's the code:
#import <Foundation/Foundation.h>
@interface testLabelThingy : NSObject
@property (strong) IBOutlet NSTextField *daLabel;
- (id) init;
- (void)changeLabel;
- (IBAction)daButton:(id)sender;
@end
and:
#import "testLabelThingy.h"
@implementation testLabelThingy
@synthesize daLabel;
- (id) init{
self.daLabel = [[NSTextField alloc] init];
return self;
}
- (IBAction)daButton:(id)sender{
[self changeLabel];
}
- (void)changeLabel{
NSLog(@"Change Label Function. Current value is: %@", [self.daLabel stringValue]);
if([[self.daLabel stringValue] isEqualToString:@"Bloog"]){
[self.daLabel setStringValue:@"Blarg"];
}else{
[self.daLabel setStringValue:@"Bloog"];
}
}
@end