将NSMutableArray传递给NSWindowController [英] Pass an NSMutableArray to a NSWindowController

查看:193
本文介绍了将NSMutableArray传递给NSWindowController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我创建一个NSWindowController如下:

So I am creating a NSWindowController like so:

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

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

I am then passing this object an array that I will be using for a NSTableView

[ summaryWindow setGlobalStatusArray:globalStatusArray];

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

Once that object is created, I realize I have don't know how to do something fundamental which is to link the newly created object actions and outlets. If I create a object in the xib, and link up the methods, I can run an action but I don't have access to the array because the xib created a separate instance of the NSWindowController, so how would one programmatically create the NSWindowController but also pass an array to it.

推荐答案

所以我最后通过NSNotifications这样做,并通过userInfo传递信息。

So I just ended up doing this via NSNotifications, and passing the Information via the 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];

这篇关于将NSMutableArray传递给NSWindowController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆