PDA

View Full Version : How can I update the NSTableView immediately?


Mars_999
2004.01.14, 11:48 PM
Is it possible to send some command to have the view redraw the table without having to open and close it again to see the updated data? Thanks

Mark Levin
2004.01.15, 12:24 AM
-(void)reloadData;

skyhawk
2004.01.15, 02:13 AM
and if you want it to happen automatically, hook it to an NSTimer to fire off like, oh once every second

Mars_999
2004.01.15, 01:07 PM
ok, well then how do I call this function like I would in C++? I am learning ObjC still


//C++ code
void foo(void);
int main(int argc, const char *argv[])
{
foo();
return 0;
}

//here is the function I need called from someother function in my app
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex



thanks

skyhawk
2004.01.15, 02:55 PM
you wouldn't call this function like you would in C++ ugh

anyways, if you are calling from within your table class, you would say [self reloadData];

outside, you would just say [classname reloadData];

imported_kelvin
2004.01.16, 01:14 AM
an important thing to note is, when reloading data for a tableview, unless you're using -reloadItem: then you have to re-expand all the items that were expanded in order to maintain the UI. Just calling -reloadData will have the annoying affect of snapping shut your table tree. What you need to do is iterate though the table lines and check to see if the line is expanded. Then once you -reloadData, iterate through again and expand them to the state they were in. Also becareful when deleting rows, as you'll need some robust code to handle all the expansion cases with parent and subnodes getting deleted together.