Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.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 基于视图的NSTableView从外部Nib,子视图未初始化_Objective C_Macos_Nstableview - Fatal编程技术网

Objective c 基于视图的NSTableView从外部Nib,子视图未初始化

Objective c 基于视图的NSTableView从外部Nib,子视图未初始化,objective-c,macos,nstableview,Objective C,Macos,Nstableview,我试图了解OSX上基于视图的NStableView 我的问题是,在加载的视图单元(NSView子类)中,当我尝试在委托中分配值时,子视图没有初始化 此时显示了正确的计数和正确的视图,但我无法访问子视图来指定正确的值 到目前为止我所做的: // Make my view controller the delegate _applicationTableView.delegate = self; // set the correct datasource _applicationTableView.

我试图了解OSX上基于视图的NStableView

我的问题是,在加载的视图单元(NSView子类)中,当我尝试在委托中分配值时,子视图没有初始化

此时显示了正确的计数和正确的视图,但我无法访问子视图来指定正确的值

到目前为止我所做的:

// Make my view controller the delegate
_applicationTableView.delegate = self;
// set the correct datasource
_applicationTableView.dataSource = [NWDataHolder sharedInstance];
// register the nib with the custom cell
[_applicationTableView registerNib:cellNib forIdentifier:@"ApplicationListViewCell"];
  • 使用Interface Builder中的自定义视图单元创建了xib
  • 为单元格创建自定义类并在IB中分配
这很好,我可以在调试器中看到属性。正确等级 属性是连接到正确字段的iBoules

我可以看到呼叫:

- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
NWApplicationListViewCell *cell = [_applicationTableView makeViewWithIdentifier:@"ApplicationListViewCell" owner:self];
在我的NSViewController中:
awakeFromNib
i do:

// Make my view controller the delegate
_applicationTableView.delegate = self;
// set the correct datasource
_applicationTableView.dataSource = [NWDataHolder sharedInstance];
// register the nib with the custom cell
[_applicationTableView registerNib:cellNib forIdentifier:@"ApplicationListViewCell"];
在我的
-(NSView*)表格视图:viewfortable列:行:
我有:

- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
NWApplicationListViewCell *cell = [_applicationTableView makeViewWithIdentifier:@"ApplicationListViewCell" owner:self];
返回正确的类和单元格,并且我可以访问属性。 问题是,子视图未初始化,属性为nil,无法设置新值:

Log(@"Application Name Label %@", cell.applicationNameLabel); => nil
我已经看到一些提示,子视图是懒散地初始化的,但是我找不到一种方法来进行初始化

有什么建议我做错了什么吗

谢谢,
奥利弗解决了这个问题。但我不明白为什么会发生这种情况

我将IB中的字段连接到文件所有者,但没有连接到ApplicationViewCell。
将该属性连接到这两个节点后,一切正常

解决了这个问题。但我不明白为什么会发生这种情况

我将IB中的字段连接到文件所有者,但没有连接到ApplicationViewCell。
将该属性连接到这两个节点后,一切正常

您的单元格子类有一个名为applicationNameLabel的出口,您将其连接到了xib文件中的标签?正确。我通过IB将子视图(主要是标签)连接到插座,以显示信息。我偶然发现的唯一一件事是,当我访问这些出口时,当我通过
NWApplicationListViewCell*cell=[\u applicationTableView makeViewWithIdentifier:@“ApplicationListViewCell”所有者:self]创建视图时,它们没有初始化。在此之后,子视图仍然为零。您的单元格子类有一个名为applicationNameLabel的出口,您将其连接到了xib文件中的标签?正确。我通过IB将子视图(主要是标签)连接到插座,以显示信息。我偶然发现的唯一一件事是,当我访问这些出口时,当我通过
NWApplicationListViewCell*cell=[\u applicationTableView makeViewWithIdentifier:@“ApplicationListViewCell”所有者:self]创建视图时,它们没有初始化。在此之后,子视图仍然为零。