0

所以我正在创建一个像这样的 NSWindowController:

if ( summaryWindow ) {
    [summaryWindow release];
} // end if
summaryWindow   = [[SummaryWindowController alloc] init];

然后我将这个对象传递给我将用于 NSTableView 的数组

[ summaryWindow setGlobalStatusArray:globalStatusArray];

一旦创建了该对象,我意识到我不知道如何做一些基本的事情,即链接新创建的对象动作和出口。如果我在 xib 中创建一个对象并链接方法,我可以运行一个操作,但我无权访问数组,因为 xib 创建了一个单独的 NSWindowController 实例,那么如何以编程方式创建 NSWindowController 但是还将一个数组传递给它。

4

2 回答 2

1

您只需要正确初始化窗口控制器。[[SummaryWindowController alloc] init];只是创建一个不知道其窗口的空窗口控制器,依此类推。您可以使用其 xib 文件加载它。像这样做:

summaryWindow   = [[SummaryWindowController alloc] initWithWindowNibName:@"YourWindowNIB"];
于 2011-08-18T19:49:13.963 回答
0

所以我最终通过 NSNotifications 完成了这项工作,并通过 userInfo 传递了信息。

// Register for notifications on Global Status Array updates
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(reloadTableBuffer:) 
                                                 name:StatusUpdateNotification
                                               object:nil];

像这样:

- (void) reloadTableBuffer:(NSNotification *) notification
{
    if(debugEnabled)NSLog(@"DEBUG: Was Told to Reload Table Buffer...");
    NSDictionary *globalStatusUpdate = [notification userInfo];
于 2011-08-24T05:27:17.523 回答