我有一个小问题,希望你能帮助我。我想调用一个子类窗口的实例方法并在那里设置用户界面:
//AppDelegate.h
#import <Cocoa/Cocoa.h>
@class MainView;//The main window
@interface DownloadedAppDelegate : NSObject <NSApplicationDelegate> {
IBOutlet MainView*mainview;//the objects are in the same nib, outlet connected with the window
}
@property(nonatomic,retain) IBOutlet MainView*mainview;
@end
.
//AppDelegate.m
#import "MainView.h"
@synthesize mainview;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[mainview launched];//But sometimes this code fails, I don't know why
//launched sets up the interface
}
-(void)dealloc {
mainview=nil;
}
MainView 属于 NSWindow。
有什么问题或需要改进的地方吗?我应该在其他地方建立 UI 吗?你知道为什么这段代码不总是有效吗?