我收到一个 NSRangeException 错误,我在这段非常基本的代码中找不到错误。有人可以帮助纠正我的盲点吗?
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;
}
然而应用程序崩溃:'NSRangeException',原因:' * -[__NSOrderedSetM setObject:atIndex:]: index 3 beyond bounds [0 .. 1]'