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]'