Re: NSArrayController Funkyness
Re: NSArrayController Funkyness
- Subject: Re: NSArrayController Funkyness
- From: Shawn Erickson <email@hidden>
- Date: Sat, 31 Jan 2004 07:37:03 -0800
On Jan 30, 2004, at 6:21 PM, Herr Witten wrote:
>
Hey, thanks for responding, I appreciate it, but I have provided just
>
the material that is important. I had said that all objects with the
>
same representation are deleted by these messages. Any more might have
>
been clearer but nonetheless superfluous.
Lets see...
>
> When I add several objects to an NSArrayController, display them in a
>
> table and then call remove: when one is selected, all of those with
>
> the same representation in the table disappear. That is, it removes
>
> all of the objects whose model key returns the same string and not
>
> the object itself. What can I do? Thanks
How did you remove the selected object? What method did you use? We
cannot tell.
>
> The NSArrayController is the biggest pain in the butt!
>
>
>
> It tries to do to much internally, so all of my customizations are
>
> hacks.
>
>
>
> It does not work like the rest of Cocoa.
What problem are you having... who knows? I am using NSArrayController
just fine myself...
>
> I finally fixed the problem, but it requires an ordering of commands
>
> outside of normal logic. That means that some funky-ass stufff is
>
> going on internally that I don't know about. Yuck!
What was wrong again? How did you "fix" it?
>
> Apparently, the removeObject: and removeObjects: methods are the
>
> culprits. I used them in overriding a method, so I got rid of them
>
> and things work correctly. However, I have to use them elsewhere,
>
> which poses a gigantic problem. What is there to be done?
What is wrong with those methods, how do they not behave as expected?
What did you do in your override that made them "work"?
[As we find out below it is because you did not know what they did nor
want them to do what they are designed to do. think about it... if you
send a removeObject:object to an array what should it do? remove the
first, second, or last one found, what should it consider to be the
first one, second, last, etc.]
None of your emails contained enough information in part or whole to
allow us to help by anything other then conjecture and most of us don't
have the time / desire to guess but we do like to help if give enough
information so that we can nail down how to help (or at least work
towards that if the other party is responsive).
>
The point is, I'm having
>
trouble with methods that are not mine.
>
The best response to my question would be "I've used these methods and
>
had no problems, here is what I have done..."
Which what was attempted but we didn't know enough about what you
wanted to do to offer the "what I have done" part.
>
My situation is as follows:
This is exactly what how you should have started this. (I know you
didn't know this yourself at first but...)
>
I am providing drag and drop capabilities in my tables so that rows can
>
be moved around. Thus, in the the
>
>
- (BOOL)tableView:(NSTableView *)tableView acceptDrop:(id
>
<NSDraggingInfo>)info row:(int)row
>
dropOperation:(NSTableViewDropOperation)operation
>
>
method, I need to insert the "new" objects (unarchived) and remove the
>
"old" objects afterward. To remove the old objects, I chose the
>
removeObjects: method of the ArrayController, but the trouble then
>
ensues, as it removes both the new and the old. I've also tried working
>
directly with the content, but that causes problems because of
>
****internal**** behavior involved with the associated table. Neither
>
can use indexes, because there is a modification to the array.
Ahhh... removeObject and removeObjects, as documented, remove all
matching objects from the array. So you will have to do a little index
math to get exactly what you want. Daryn has supplied a great example
of this.
>
In short, I have had a lot of trouble, and I expect more from Apple.
>
Everything else is scalable, customizable, bendable to every will and
>
whim. These seem to be troublesome.
I would fill an enhancement request about what you think is missing...
it would be great if Daryn's category, or something like it, was
provided by NSMutableArray.
http://bugreport.apple.com/
-Shawn
_______________________________________________
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.