• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Out of Bounds Exception
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Out of Bounds Exception
      • From: Andy Lee <email@hidden>
References: 
 >Out of Bounds Exception (From: email@hidden)

  • Prev by Date: Cocoa's Popularity
  • Next by Date: Re: Out of Bounds Exception
  • Previous by thread: Out of Bounds Exception
  • Next by thread: Re: Out of Bounds Exception
  • Index(es):
    • Date
    • Thread