Re: Out of Bounds Exception
Re: Out of Bounds Exception
- Subject: Re: Out of Bounds Exception
- From: Andrew Pinski <email@hidden>
- Date: Sat, 16 Mar 2002 21:44:11 -0500
I think the problem is that [DictionaryOfArrays1 objectForKey:
keyToAnArray] == [DictionaryOfArrays2 objectForKey: keyToAnArray].
So here is the flow:
self = [DictionaryOfArrays1 objectForKey: keyToAnArray];
y = [DictionaryOfArrays2 objectForKey: keyToAnArray];
//self == y
sizeOfArrayy = [y size];
for(int i=0;i<sizeOfArrayy;i++)
{
[self removeObject: [y objectAtIndex:i]];
}
I think removeObjectsInArray: has a bug when self==arrayPassed and it
should just call removeAllObjects when that happens.
So here is the flow for the fix.
self = [DictionaryOfArrays1 objectForKey: keyToAnArray];
y = [DictionaryOfArrays2 objectForKey: keyToAnArray];
if(self==y)
{
[self removeAllObjects];
}
else
{
sizeOfArrayy = [y size];
for(int i=0;i<sizeOfArrayy;i++)
{
[self removeObject: [y objectAtIndex:i]];
}
}
Thanks,
Andrew Pinski
PS Please send a bug report.
On Saturday, March 16, 2002, at 06:59 , email@hidden wrote:
I'm trying to remove the elements of one array from the elements of
another
with:
[[DictionaryOfArrays1 objectForKey: keyToAnArray] removeObjectsInArray:
[DictionaryOfArrays2 objectForKey: keyToAnArray];
Note that keyToAnArray is meant to be the same in each case and that it
is
impossible for there not to be a value associated with that key for
both.
This gives me:
Uncaught exception: <NSRangeException> *** -[NSCFArray objectAtIndex:]:
index
(1) beyond bounds (1)
What is the problem? Thank you.
_______________________________________________
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.