Crashing while trying to move UITableView rows

后端 未结 7 810
北恋
北恋 2021-01-06 01:13

I\'ve got some rather complicated rules for moving rows around in a UITableView. There are an undefined number of sections and rows per section, and based on v

7条回答
  •  花落未央
    2021-01-06 02:05

    Seems like something somewhere is requesting element 6 from an array that only has elements at indexes 0-5 (meaning 6 elements).

    This usually happens when the code tries to do:

    NSUInteger index = [somearray count];
    id obj = [somearray objectAtIndex:index];
    

    because count is upper boundary and arrays start from 0 the last element is at count - 1.

    This might not be directly in your code but you may be restricting something to a number of elements and then requesting one past the last element.

提交回复
热议问题