开发者

NSTableView not updating like I think it should

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


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.


Within updateServerList you should [crazyStuff noteNumberOfRowsChanged]. I thought reloadData causes the table to re-ask its dataSource for the numberOfRowsInTableView:, though...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜