Re: NSArrayController can't insert object
Re: NSArrayController can't insert object
- Subject: Re: NSArrayController can't insert object
- From: Dustin Voss <email@hidden>
- Date: Mon, 10 May 2004 10:12:13 -0700
On 10 May, 2004, at 7:56 AM, Timothy Larkin wrote:
I have a window with two tables. One table shows the result of
searches of the Library of Congress. The other table shows the
contents of my library. When the second table shows all the records,
I can drag items from the LOC table and add them to my local table.
My local table also has an NSSearchField that can filter the items
shown in the table. The problem comes when the local table shows a
subset of my entire library. If I drag a new item from the LOC table
to the local table, an exception is raised by [NSArrayController
_assertFilterRestrictsInsertionOfObjects:atArrangedObjectIndexes:],
and the item is not added. (This happens whether or not the search
string in the NSSearchField would select the new record.) However, if
the book from the LOC table is the same book as one that appears in
the filtered local table, the assertion is not triggered, and the
addition is allowed to complete.
There is an article on filtering at
<
http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaBindings/Tasks/filtering.html#//apple_ref/doc/uid/20002302>. Maybe
you could use it as a model.
What is this filter that's implied by
_assertFilterRestrictsInsertionOfObjects? It seems as though there's
some rule saying that if the arranged object array is not the same set
as the content array, new items cannot be added to the arranged object
array.
Since [NSArrayController insertObject:atArrangedObjectIndex:]
"inserts object into the receivers arranged objects array at the
location specified by index, and adds it to the receivers content
array", the arranged object array will still be a subset of the
content array, so there shouldn't be any reason to forbid making
additions to the arranged object array.
Any way around this problem?
Someone else probably has a better idea of what's going on here. The
only thing I can think of an immutable filtered array.
_______________________________________________
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.