NSRangeException from removeObjectsInRange:但传递的范围在bounds内 [英] NSRangeException from removeObjectsInRange: but passed range is within bounds
问题描述
我收到以下错误,这没有任何意义。
*由于未捕获异常终止应用程序'NSRangeException' ,原因:'* - [NSMutableArray removeObjectsInRange:]:range {11,15}扩展超出边界[0 .. 15]'
我在这里做错了什么?我在数组的界限内。删除数组中的最后一个对象是否会导致问题?
NSRange
是长度,而不是端点。
$ b
$ b
[myArray removeObjectsInRange:(NSRange){11,5}];
I am getting the error below, which makes no sense.
* Terminating app due to uncaught exception 'NSRangeException', reason: '* -[NSMutableArray removeObjectsInRange:]: range {11, 15} extends beyond bounds [0 .. 15]'
What am I doing wrong here? I am within bounds of the array. Does removing the last object in the array cause issues?
The second field of an NSRange
is length, not endpoint. You are trying to remove fifteen objects, starting from index 11.
Instead, you want to do something along the lines of:
[myArray removeObjectsInRange:(NSRange){11, 5}];
这篇关于NSRangeException from removeObjectsInRange:但传递的范围在bounds内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!