What does the iOS error “request for rect of invalid section” mean?

前端 未结 3 665
猫巷女王i
猫巷女王i 2021-01-12 02:07

Google reveals no posts at all for this error message. I\'m getting it in iOS 5 trying to update a UITableView. While the exact code is a bit tortured, this is what I\'m doi

3条回答
  •  深忆病人
    2021-01-12 02:54

    Looks like your code is trying to work with a section of your table that does not exist.

    Since NSArrays are zero-indexed, the index value of count will be outside the bounds of the array. You should subtract one from the count when using indexSetWithIndex: here:

    [table insertSections: [NSIndexSet indexSetWithIndex: [sections count]-1] 
                                        withRowAnimation: UITableViewRowAnimationNone];
    

提交回复
热议问题