我想在另一个类的文本字段中设置一个文本并从另一个类中获取它。这是我想要的,但它不起作用。你能帮我么。谢谢!
啊啊啊
#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