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

  • SEARCH
  • Home
  • 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 8662223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:40:54+00:00 2026-06-12T16:40:54+00:00

I am getting a NSRangeException error and I can not find the error in

  • 0

I am getting a NSRangeException error and I can not find the error in this very basic bit of code. Can someone help correct my blindspot?

uint32_t offsetVal = 0;
int num = 100;
_offsetVals=[[NSMutableOrderedSet alloc]initWithCapacity:num+1];
for (int i=0; i<=num; i++) // note: there is 1 greater offset record than there is glyphs!
{
    CFDataGetBytes(tableData, CFRangeMake(offset,4),(UInt8*)&offsetVal);
    offsetVal=CFSwapInt32HostToBig(offsetVal);
    [_offsetVals insertObject:[NSNumber numberWithInt:offsetVal] atIndex:i];
    offset+=4;
}

Yet the app crashes with:
‘NSRangeException’, reason: ‘* -[__NSOrderedSetM setObject:atIndex:]: index 3 beyond bounds [0 .. 1]’

  • 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-12T16:40:55+00:00Added an answer on June 12, 2026 at 4:40 pm

    The issue was that a NSMutableOrderedSet regards the initial capacity as a hint rather than an instruction, so insert failed within a few because the system hadn’t allocated the necessary space. From the manual (but not within the insertObject text):

    “NSMutableOrderedSet objects are not like C arrays. That is, even though you may specify a size when you create a mutable ordered set, the specified size is regarded as a “hint”; the actual size of the set is still 0. This means that you cannot insert an object at an index greater than the current count of an set. For example, if a set contains two objects, its size is 2, so you can add objects at indices 0, 1, or 2. Index 3 is illegal and out of bounds; if you try to add an object at index 3 (when the size of the array is 2), NSMutableOrderedSet raises an exception.”

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

Sidebar

Related Questions

Getting this weird LINQ error. title = System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.Xml.Linq.XElement,System.String Here is the code I have:
Getting this error when I follow the simple code example from jsoncpp, that basically
I'm getting quite a lot of crashes like this. In my code, I'm not
when i scroll table view data then i am getting this error ** Terminating
Getting this error: 'NSInvalidArgumentException', reason: '-[EngineerModel _isNaturallyRTL]: unrecognized selector sent to instance I've read
Getting an error when working in my local environment, but exact same code pushed
Getting this error, what does it mean here. [mediaPlayTime setText:[NSString stringWithFormat:@%@ / %@, [self
Getting some compiler/ lint errors for this code. Don't get what they mean, Does
I am getting the following error please help me with a solution. My xcode
Getting this error when I put use Blog; at the top. Warning: The use

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.