Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSMutableArray index 9223372036854775807 beyond bounds [closed]

I found this via a crash report:

*** -[__NSArrayM objectAtIndex:]: index 9223372036854775807 beyond bounds [0 .. 8]
CoreFoundation-[__NSArrayM removeObjectAtIndex:]

This is the code responsible:

[self someMethodwithCallback:^(NSMutableArray *stickerArray)
{
   _tableViewController.tableView beginUpdates];

   _layersArray = stickerArray;

   NSArray *reversed = [[_layersArray reverseObjectEnumerator] allObjects];

   _layersArray = [reversed mutableCopy];

  [_tableViewController.tableView insertRowsAtIndexPaths:@[[NSIndexPath indexPathForRow:0 inSection:0]] withRowAnimation:UITableViewRowAnimationAutomatic];

  [_tableViewController.tableView endUpdates];

  [_tableViewController.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionNone];

  [_delegate stickerSelectedAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
}

How and where would this huge index be happening?

like image 561
daihovey Avatar asked Mar 13 '14 22:03

daihovey


1 Answers

I believe the index in question is NSNotFound.

You're probably getting index from the result of a "find in array" operation (or the location of an NSRange returned from one)

like image 186
nielsbot Avatar answered Sep 20 '22 07:09

nielsbot