Changing NSTableView DataSource without glitching
Changing NSTableView DataSource without glitching
- Subject: Changing NSTableView DataSource without glitching
- From: Jerry Krinock <email@hidden>
- Date: Wed, 15 Mar 2006 17:36:12 -0800
- Thread-topic: Changing NSTableView DataSource without glitching
I use several NSTableView and NSOutlineView, and have found that crashes or
out-of-range exceptions occur sporadically if I change the data in the
DataSource while the table is being displayed; for example, if the
DataSource delegate methods read data from an NSArray instance variable, and
I do [setArray: newArray].
The solution I have found is to set the DataSource to nil, make my changes,
and then "reconnect" it and finally -reloadData...
[myTableView setDataSource:nil] ;
[self setArrayFromWhichDataIsTaken:newArray] ;
[myTableView setDataSource:self] ;
[myTableView setDelegate:self] ;
[myTableView reloadData] ;
This makes sense heuristically and has been proven experimentally and in the
field. But can anyone explain this based on Cocoa documentation?
Jerry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden