Re: NSArrayController selection bug?
Re: NSArrayController selection bug?
- Subject: Re: NSArrayController selection bug?
- From: Henrik Wittland <email@hidden>
- Date: Tue, 11 Nov 2003 00:46:44 +0100
Am 10.11.2003 um 23:49 schrieb Jesse Grosjean:
mmalc,
As far as I'm aware (**although this is the subject of some debate,
for which I'm awaiting resolution**) this isn't a bug.
The array itself is not observed, so you're changing the array behind
the controller's back. Granted you're calling setContentArray, but
you're passing in the same object, so I'd guess that there's some
optimisation to ensure no notification is sent. The appropriate thing
to do is either to send a message to the controller (which seems like
a fairly logical thing to do since it's managing the display...?) or
implement the mutable array accessors and call
removeObjectFromContentArrayAtIndex:
I think what I'm seeing is a different case. I'm pretty sure that the
NSArrayController does get notified of my change, but the problem is
that it's using invalid cached state (the selected indexes) to update
itself.
I've added an extra action to your test application ("remove UMA") that
will show the problem. Add a few objects, and then, making sure that
the last object in the tableview is selected, click the new "remove
UMA" button. You should see an index of of bounds exception.
The BUG is also present when you not select the last object. But that
is only a display error.
The NSArrayController selects the wrong object. It should select with
object identity but it is
selecting with the old indexset.
In the case of an immutable array it is selecting by equality (equal:).
I've put an example of the different cases at:
http://homepage.mac.com/mmalc/CocoaExamples/AddBehindTheScenes.zip
Thanks, I've attached a version with my additions.
[demime 0.98b removed an attachment of type application/zip which had
a name of AddBehindTheScenes.zip]
Jesse
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.