Re: NSTableView Drag & Drop... Well, Maybe
Re: NSTableView Drag & Drop... Well, Maybe
- Subject: Re: NSTableView Drag & Drop... Well, Maybe
- From: mw <email@hidden>
- Date: Wed, 09 Oct 2002 19:06:13 -0400
>
> Whenever any element of the array that was brought
>
> from the pasteboard is accessed, an EXEC_BAD_ACCESS error is returned.
>
> Remember, this array was just brought down from a "freeze-dried" state as an
>
> NSData object back into an NSMutableArray. This takes place in the second
>
> loop, as previously stated.
>
>
Are you retaining them when you unarchive them? You're supposed to, I
>
believe. I ask, because it feels like your problem comes from a failure to
>
retain something pretty early in your problem scenario.
>
>
> 2002-10-08 16:10:53.117 RaiseMan[1712] *** -[NSConcreteMutableData
>
> objectAtIndex:]: selector not recognized
>
>
>
> My guess is that this error is being returned because it is attempting to
>
> send a message to a dangling pointer. The employees array stores a group of
>
> custom data type objects (subclass of NSObject, of course). Do I have to
>
> impliment the NSCopying protocol so I can, perhaps, send a [MyObject copy]
>
> message when inserting it (or them) into the array that is to be archived as
>
> an NSData object for pasteboard placement?
>
>
I get the selector not recognized error under these circumstances (dangling
>
pointer), so your first supposition seems right. That's why I say it feels
>
like a failure to retain something early on. If it were a failure to adopt
>
the NSCopying protocol when required to do so, you would probably see a
>
"copyWithZone: selector not recognized" error.
Well, I found several stupid mistakes on my part. For one, in the method
call to archive the NSMutableArray into an NSData object, for some reason I
passed the NSData object to NSArchiver instead of the NSMutable array. Duh!
So that all seems to be going fine and good, but now I keep getting
out-of-range errors when inserting objects into the main employees array.
For example, this code:
while(index = [e nextObject]) {
[employees insertObject:[unarchivedPeople objectAtIndex:i]
atIndex:(unsigned)row];
i++;
row++;
}
Seems to SOMETIMES have a problem with the first line in the while loop:
[employees insertObject:[unarchivedPeople objectAtIndex:i]
atIndex:(unsigned)row];
There seems to be no problem if, in the table view, an entry is moved UP the
list, but I constantly get an out-of-bounds error whenever a name is moved
DOWN the list. This is the exact error message:
2002-10-09 18:13:47.713 RaiseMan[726] *** -[NSCFArray
insertObject:atIndex:]: index (2) beyond bounds (2)
This is very strange to me because, in my tester list, there are only two
entries. Moving up the list would mean moving from array location 1 to 0,
and all allocated arrays have a 0th location.
Btw, I have to typecast row to unsigned manually because it kept sending -1
to the insertObject: message as row is passed as an int. It fixed the
problem though...
Any thoughts? This is probably just another stupid error (as most are when
it comes to dealing with array indices).
mw
_______________________________________________
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.