开发者

iOS Development: Why doesn't loadScoresWithCompletionHandler ever return?

I'm playing with the Game Kit API and I have a very simple block of code that never returns, not even with an error...

GKLeaderboard *pointsRequest = [[GKLeaderboard alloc] initWithPlayerIDs:[match playerIDs]];
if (pointsRequest != nil)
{
    //Set the points leaderboard category id
    [pointsRequest setCategory:kPOINTS_LEADERBOARD_ID];
    [pointsRequest loadScoresWithCompletionHandler: ^(NSArray *scores, NSError *error) 
    {
       if (error != nil)   //THIS LI开发者_开发知识库NE NEVER GETS HIT
       {
          NSLog(@"%@", [error localizedDescription]);           
       }

       if (scores != nil)  //NOR DOES THIS LINE
       {
        .
        .
        .

Since there's no error, I'm unsure of how to even troubleshoot this. Does anyone have any ideas what's wrong or how I can further investigate what's wrong?

Thanks so much for your wisdom!

UPDATE: I was finally able to get this block of code to return, tho I don't fully understand why. To get it to return, I posted a score to the leaderboard shortly before trying to retrieve it. What's strange is I had a score posted there before, so I don't know why posting a score had any effect on this problem.


This actually might be a bug that just got corrected in the iOS 4.3 beta.

From the developer notes (source: gadgetsdna.com)

FIXED: GameKit now reports an error when achievement or a leaderboard score is not actually submitted.

I'm not a 100% sure this is related to your problem, but the only way to find out is either to enroll in the iOS developer program and test the latest beta or wait for the final iOS 4.3 SDK to come out.


The problem occurred when trying to load scores for new players who didn't have any scores on the leaderboard already posted. It turns out that those "if" statements were getting hit, but the blocks of code under them weren't since there was no error and there were no scores. Anyhow, it was a dumb mistake on my part. Thanks to DavidD, however, for his contribution. Even tho his answer was unrelated to the problem, I still learned something.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜