There's this line:
NSMutableArray *finalArray = [[NSMutableArray alloc] init];
....followed shortly by this one:
NSNumber *highscore2 = [finalArray objectAtIndex:0];
After the first of these lines, finalArray
is a mutable array that contains no objects. On the second of these lines, you try to look up the object at index 0. Except that you haven't added any objects to finalArray
, so there is no object at index 0. That's illegal, so you get an exception and a crash. I'm not sure what you're trying to do with finalArray
, but you can't look up objects in an array unless it actually contains some objects. You should check the array count before doing the lookup.