在WindowController中加载NIB之前需要反映更改 [英] Changes needs to be reflected before the NIB loads in WindowController

查看:110
本文介绍了在WindowController中加载NIB之前需要反映更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要加载我的windowController的nib文件。

I want to load the nib file of my windowController.

我从AppDelegate调用windowController类

I am calling the windowController class from AppDelegate

-(IBAction)test:id(sender)
{
//Loading the WindowController Class

   Test1 *wc = [[Test1 alloc]init]alloc];

   [wc showWindow:self];

/*Some code Changes done*/

/*Changes done to add value to the text Field of the Window Controller*/
}

获取窗口控制器XIB的值时进行了一些更改,

There are few changes made to get the value of the Window Controller XIB,

在Test1Class中,使用以下检索值:

In the Test1Class, the values is retrieved using:

- (id)initWithWindow:(NSWindow *)window
{

//Code added to retrieve the Text Field data

}

但是当窗口启动时,所做的更改没有反映出来。

But when the window launches the changes made is not getting reflected.

但是当放置断点时,但是没有显示在TextField上,但是在XIB中IBOutlet已经为NSTextField连接,因为IBoutlet的值没有设置。

But when putting the breakpoints, the value is getting set but is not getting to show on the TextField, But in XIB IBOutlet has been connected for the NSTextField, for the IBoutlet value is not getting set.

感谢提前! !

推荐答案

当您尝试设置IBOutlet指针时,是否为零?

Is the IBOutlet pointer nil when you are trying to set it?

awakeFromNib:比init做的更好,我认为你想做的。出口在初始化期间很可能为零,您不会收到任何警告,不会向其分配任何内容。

awakeFromNib: is a better place than init to do what I think you're trying to do. Outlets are fairly likely to be nil during init, and you'll get no warning doing an assignment to them.

这篇关于在WindowController中加载NIB之前需要反映更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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