问题
I met a problem about the NSTableView
, and it is like:
one datasource of tableview is called:
- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
return [self.dataArray count];
}
But this one is never called:
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
// the code
}
I have checked the the array really had data, and also checked the
[NSTableView reloadData]
was called in the main thread.
SO I'm totally lost about this weird problem. Would any one give some tips? thanks!
回答1:
I moved the initial code from awakeFromNib
to the init
, and it called correctly. But I still don't know the real reason. I guess it matters with the life-cycle of the view because the class which has the tableview is a subclass of NSObject
and not of NSViewController
.
来源:https://stackoverflow.com/questions/12245113/nstableview-only-numberofrowsintableview-datasource-is-called