5

Exception:

request for rect at invalid index path

Code:

CGRect rect = [tableView rectForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];

Fix:

if ([tableView numberOfRowsInSection:0] <= i) {
    return;
}

Maybe exist the better way

Alex Sfinx87
  • 244
  • 5
  • 16

1 Answers1

3

Usually rectForRowAtIndexPath could handle invalid indexPath as document states, but in IOS 7.1, it does not handle invalid indexPath properly. So passing in nil would cause crash and get the error message:

request for rect at invalid index path ( {length = 2, path = 0 - 0})

In a word, manually do a nil check is necessary for rectForRowAtIndexPath.

Shubh
  • 6,693
  • 9
  • 48
  • 83
violion
  • 31
  • 2