Я пытаюсь реализовать подкласс NSWindowController с новым xib-файлом, я прочитал много книг и исследовал StackOverflow, но ни один из представленных шагов не сделал мое окно show, а также не выполнялся код подкласса. Новый xib-файл имеет владельца своего файла, установленного в «LogNavigatorController», и подключения к окну и его содержимое было сделано.Как правильно реализовать подкласс NSWindowController с xib-файлом
Мои AppDelegate.h:
#import <Cocoa/Cocoa.h>
@class LogNavigatorWindowController;
@interface AppDelegate : NSObject <NSApplicationDelegate>
{
LogNavigatorWindowController *logsWindowController;
}
@end
Мой AppDelegate.m:
#import "AppDelegate.h"
#import "LogNavigatorWindowController.h"
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
logsWindowController = [[LogNavigatorWindowController alloc] initWithWindowNibName:@"LogNavigatorWindowController"];
[logsWindowController showWindow:self];
}
@end
Мой LogNavigatorWindowController.h:
#import <Cocoa/Cocoa.h>
@interface LogNavigatorWindowController : NSWindowController
{
NSArray *directoryList1;
NSArray *directoryList2;
NSMutableArray *directoryList;
NSMutableArray *filePaths1;
NSMutableArray *filePaths2;
}
@property (assign) IBOutlet NSWindow *window;
@property (weak) IBOutlet NSTableView *logsTableView;
@property (unsafe_unretained) IBOutlet NSTextView *logsTextView;
@property (assign) IBOutlet NSArrayController *LogListController;
@property (retain) NSMutableArray *logsArray;
- (void) myDirectoryLogFunction;
@end
Мой LogNavigatorController.m:
#import "LogNavigatorWindowController.h"
@interface LogNavigatorWindowController()
@end
@implementation LogNavigatorWindowController
@synthesize logsTableView;
@synthesize logsTextView;
@synthesize window;
- (id)init
{
self = [super initWithWindowNibName:@"LogNavigatorWindowController"];
[self loadWindow];
[self showWindow:@"Log Navigator"];
[self.window makeKeyAndOrderFront:nil];
if (self)
{
// Initialization code here.
[self myDirectoryLogFunction];
}
return self;
}
- (void)windowDidLoad
{
[super windowDidLoad];
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
}
- (void) myDirectoryLogFunction
{
NSLog(@"Code execution test successful");
}
@end
'NSWindowController' уже имеет свойство' window' ', поэтому я подозреваю, что вы поставили свою проблему. – trojanfoe
Спасибо @trojanfoe Удалено свойство и его код реализации (синтезируется), все еще нет кубиков. –