Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c NSWindowController和isWindowLoaded_Objective C_Cocoa_Nswindow - Fatal编程技术网

Objective c NSWindowController和isWindowLoaded

Objective c NSWindowController和isWindowLoaded,objective-c,cocoa,nswindow,Objective C,Cocoa,Nswindow,我有一个NSWindowController,我像这样初始化它 + (MyWindowController *) sharedController { static MyWindowController *singleton = nil; if (!singleton) singleton = [[self alloc] initWithWindowNibName: @"myWindow"]; return singleton; } [[MyWindowControl

我有一个NSWindowController,我像这样初始化它

+ (MyWindowController *) sharedController
{
    static MyWindowController *singleton = nil;

    if (!singleton) singleton = [[self alloc] initWithWindowNibName: @"myWindow"];
    return singleton;
}
[[MyWindowController sharedController] showWindow: nil];
我展示的是这样的窗户

+ (MyWindowController *) sharedController
{
    static MyWindowController *singleton = nil;

    if (!singleton) singleton = [[self alloc] initWithWindowNibName: @"myWindow"];
    return singleton;
}
[[MyWindowController sharedController] showWindow: nil];

现在的问题是,我需要从该窗口上的一些控件获取信息。但是如果窗口还没有加载,我不想加载它,因为这样我就可以使用默认值了。我应该使用isWindowLoaded吗@属性来访问singleton?或者这里推荐什么?(如果是@property,那么也请给我只读的非原子属性。)

不要在视图中存储模型数据。让控制器(可能不是MyWindowController,而是需要数据的控制器)拥有真实数据(如果有)并填写任何默认值

在Interface Builder中填写的任何值都只用于调整大小


例如,如果我知道一个字段必须包含一个值为±50000的数字,我将输入“-50000”并相应调整字段大小,并将“-50000”保留在那里。实际默认值更可能是0或其他值,我将使用拥有该值的控制器提供的值(或者,如果字段显示模型对象的属性,我将使用每个新模型对象提供的默认值)。

谢谢。关于某些控件的信息,我实际上是指复选框的状态(只是为了确保)。。我不太明白你想对我说什么。我应该在IB中有一个接口元素连接到该对象而不是NSWindowController的对象吗?