Re: NSTableView prematurely posts selection changed notification
Re: NSTableView prematurely posts selection changed notification
- Subject: Re: NSTableView prematurely posts selection changed notification
- From: "Joan Lluch (casa)" <email@hidden>
- Date: Thu, 10 Jul 2008 19:05:33 +0200
El 10/07/2008, a las 5:21, Graham Cox escribió:
When my app starts up, it opens a floating window containing a table
view. As the table is brought to life from the Nib, it posts a
"selection changed" notification to its delegate. At that time it
hasn't had its data initialised from the data model so the selected
row is 0. This causes an undesirable change to the data model.
Yes, this is an annoying behaviour. I ran some time ago with the same
issue and I ended giving up, because after all it was not such a big
issue in my app. To my knowledge, which is not much compared to some
other members of this forum, this is not an easy task nor a bug,
because it already does what it is supposed to to as far as KVO
notifications is concerned. What triggers the change here is the
selection state of the TableView, not the model, so the model gets
updated as a consequence.
The only way I think of to overcome this problem is to load the
TableView without the selection binding, set manually the selected
row, and then establish the binding with the model.
Another possible approach is to cache the selected row (according to
the model) just before the nib loads, and then manually re-set it
after the nib has loaded, regardless of what its current value is now.
However in this case you might have to turn temporarily off the undo
manager to avoid registering for that 'phantom' change.
I didn't try any of the above though. I will be interested in your
developments with regard to this subject, though.
Joan Lluch_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden