Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8895693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:50:59+00:00 2026-06-14T23:50:59+00:00

I get NSRangeException error when I try to removeObjectAt:0 . I don’t know how

  • 0

I get NSRangeException error when I try to removeObjectAt:0 . I don’t know how that is even possible.

-(void)removePoints:(ccTime *)tm
{

    NSLog(@"naughty %@",_naughtytoucharray);
    if ([_naughtytoucharray count]>0)
    {
        [_naughtytoucharray removeObjectAtIndex:0];
    }
}

shows on log:

[4195:c07] naughty (
"{124, 98}",
"{123, 98}",
"{135, 97}",
"{124, 98}",
"{148, 94}",
"{135, 97}",
"{157, 93}",
"{148, 94}",
"{162, 92}",
"{157, 93}",
"{164, 92}",
"{162, 92}"
)

then I get the following error:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 11 beyond bounds [0 .. 10]'

When I set a breakpoint I see all objects are 0x0

enter image description here

NSMutableArray is allocated and initialized in init and filled in ccTouchesMoved

-(void) ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event  {


    if (isSelected) {

        UITouch *touch = [ touches anyObject];
        CGPoint new_location = [touch locationInView: [touch view]];
        new_location = [[CCDirector sharedDirector] convertToGL:new_location];


        CGPoint oldTouchLocation = [touch previousLocationInView:touch.view];
        oldTouchLocation = [[CCDirector sharedDirector] convertToGL:oldTouchLocation];
        oldTouchLocation = [self convertToNodeSpace:oldTouchLocation];

        // add my touches to the naughty touch array
        [_naughtytoucharray addObject:NSStringFromCGPoint(new_location)];
        [_naughtytoucharray addObject:NSStringFromCGPoint(oldTouchLocation)];

    }
}

Any idea why I cannot remove the first item of the array?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:51:01+00:00Added an answer on June 14, 2026 at 11:51 pm

    That’s not where your error is coming from. The method it’s complaining about is objectAtIndex:, not removeObjectAtIndex: and the index causing the error is eleven, not zero.

    Look for a place in your code where you are assuming that there are at least 12 objects in the array while reading from it. There are only eleven and their indexes are 0-to-10.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get Compiler Error C2248 when i try to compile the following code: #include
I get the following error even when my JAVA_HOME is set correctly. C:\workspace-sts-2.8.0.RELEASE\JBClient\target>echo %JAVA_HOME%
When i use @try @catch, i get error: expected identifier or '(' before 'try'
This is error in the log console that I get when I run my
I get this error while accessing a php script: W/System.err: Error reading from ./org/apache/harmony/awt/www/content/text/html.class
I get this error when running my iPhone app 2009-12-05 21:32:06.711 iTour[7595:207] *** Terminating
Get the following error periodically in an IIS application: Failed to load resources from
.get() converts a jQuery object to a DOM element that Javascript can use without
I get an error on String(u).indexOf() saying access denied http to https... so I'm
I have this error in xcode: Terminating app due to uncaught exception 'NSRangeException', reason:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.