別のクラスのテキスト フィールドにテキストを設定し、別のクラスから取得したいと考えています。これは私が欲しいものですが、うまくいきません。手伝ってくれませんか。ありがとうございました!
aaa.h
#import <Cocoa/Cocoa.h>
@interface aaa : NSImageView {
IBOutlet NSTextField *message;
}
@property (nonatomic, retain) IBOutlet NSTextField *message;
@end
aaa.m
#import "aaa.h"
#import "bbb.h"
@implementation aaa
@synthesize message;
- (void)awakeFromNib {
// [message setStringValue:@"ok, this works!"]; //but i don't want it from here
[self hello];
}
@end
bbb.h
#import <Foundation/Foundation.h>
@interface NSObject (bbb)
- (void)hello;
@end
bbb.m
#import "bbb.h"
#import "aaa.h"
@implementation NSObject (bbb)
- (void)hello {
aaa *obj = [[[aaa alloc] init] autorelease];
[obj.message setStringValue:@"This doesn't work :("]; // set text here, dont work.
NSLog(@"TEST: %@", [obj.message stringValue]);
}
@end