这可能是一个很容易回答的问题,但对于我来说,我似乎无法让这个问题发挥作用。
我正在使用Objective-C为MacOSX开发,并创建一个自定义类(appcontroller.h和.m)。我亲手写了两个iboutlets(nstextfield,nsImageView),确保在.h中执行“@property”行,在.m文件中执行“@synthesis”。我通过拖动nsObject文件并将其类设置为AppController,然后进行连接,确保在Interface Builder中链接它们。
我没有收到任何错误,但当我执行这样一个非常简单的调用时:
[标题setalphavalue:0.0];
什么都没发生。你们能照到的任何光都会很棒。
我的代码:
应用程序控制器
#import <Cocoa/Cocoa.h>
@interface AppController : NSObject {
IBOutlet NSImageView *movie_icon;
IBOutlet NSTextField *title;
}
-(void)startUp;
@property (nonatomic, retain) NSImageView *movie_icon;
@property (nonatomic, retain) NSTextField *title;
@end
AppMulk控制器
#import "AppController.h"
@implementation AppController
@synthesize title;
@synthesize movie_icon;
-(void)startUp{
NSLog(@"Starting App Controller...");
[title setAlphaValue:0.0];
}
@end
主m
#import <Cocoa/Cocoa.h>
#include "AppController.h"
int main(int argc, char *argv[])
{
AppController *ctrl;
ctrl = [[AppController alloc] init];
[ctrl startUp];
return NSApplicationMain(argc, (const char **) argv);
}