问题
I have the following code:
- (void)updateServerList {
[crazyStuff reloadData];
NSLog(@"Hi");
}
- (int)numberOfRowsInTableView:(NSTableView *)tableView
{
NSLog(@"Numbers have Changed");
return [serverBrowser.servers count];
}
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn
row:(int)row
{
NSLog(@"Starting updates for table");
NSNetService* server = [serverBrowser.servers objectAtIndex:row];
return [server name];
}
- (IBAction)tableViewSelected:(id)sender
{
//row = [sender selectedRow];
NSLog(@"the user just clicked on row ");
}
This is part of a chat program that I'm trying to expand. It was designed for the iOS and I'm working to get it to work on my laptop and chat with my iPad. I know that updateServerList
is called correctly from my log statement. I also now that numberOfRowsInTableView:
is called on startup but not anytime else. I would like to have my Table (the outlet crazyStuff) updated everytime updateServerList
is called. How would I trouble shoot to see if it is or is not? I am not seeing the data show up in the table that "should" be there
回答1:
I take it then that at startup, when numberOfRowsInTableView is called, it returns 0? If not, is tableView:objectValueForTableColumn:row: ever called then?
My first guess would be the "crazyStuff" is, in fact, not connected to anything or connected to something other than the table view you intend. Might want to log the value of crazyStuff in updateServerList.
回答2:
Within updateServerList
you should [crazyStuff noteNumberOfRowsChanged]
. I thought reloadData
causes the table to re-ask its dataSource
for the numberOfRowsInTableView:
, though...
来源:https://stackoverflow.com/questions/5137213/nstableview-not-updating-like-i-think-it-should