I’m creating a NSTextView in my AppController.h:
@interface AppController : NSObject {
IBOutlet NSTextView *texto;
}
@property (assign) IBOutlet NSTextView *texto;
@end
After connected and properly checked, I’m trying to set a texto for this TextView from another class (AppMenu.m), but with no luck:
#import "AppController.h"
- (IBAction)setText:(id)sender {
AppController *appControl = [[AppController alloc] init];
[[appControl texto] setString:@"Hello"];
}
What should I do?
The problem is that Appmenu creates a new instance of texto, a local one just for appmenu (with the same properties), and not setting properties on the one actually in appcontroller. If you try debugging, you’ll see that the two texto objects have different memory pointers.
You could make appcontroller the delegate for appmenu and create a ‘setTextoProps’ method which can pass data from appmenu over to appcontroller.
You could also make an instance of storyboard.appcontroller and set data directly with something like