csddavies/DDGameKitHelper — pull request #3 by insanehunter (2012-03-29 08:49:42+00:00)
Title: Fixed crash due to empty `playerScores` array in iOS 4.1

I've found an issue in a live application. Users with iOS 4.1 experience crashes with the following logs:

*** -[NSMutableArray objectAtIndex:]: index 0 beyond bounds for empty array

CoreFoundation 0x30897ec1 __exceptionPreprocess 96
1 libobjc.A.dylib 0x3002f811 objc_exception_throw 24
2 CoreFoundation 0x30829d79 -[__NSArrayM objectAtIndex:] 184
3 MyApp 0x0003412d __block_global_0 (in MyApp) (DDGameKitHelper.m:294)
4 GameKit 0x3514dcb3 __-[GKLeaderboard loadScoresForGame:withCompletionHandler:]_block_invoke_1 658
5 GameKit 0x3516b49f __-[GKDataRequest handleResponseFromServer:error:]_block_invoke_1 34
6 libSystem.B.dylib 0x302d4984 _dispatch_call_block_and_release 20
7 libSystem.B.dylib 0x302d59fc _dispatch_main_queue_callback_4CF 220
8 CoreFoundation 0x3081f89b __CFRunLoopRun 1334
...

So it's crashing on a line:

gcScore = [playerScores objectAtIndex:0];

I have no ability to reproduct this issue, but the I suppose my fix should be enough.