Search code examples
iosobjective-cgame-centergamekit

loading achievements from GameKit always returns nil


I have a set of achievements regisgtered in iTunes connect. They are displayed on the game center UI along with the leader board. However, I am unable to load the achievement data from game center when I start up my app. In the following code snippet, the "achievements" NSArray is always 'nil'. Note that there is also no error. Thanks in advance!

[GKAchievement loadAchievementsWithCompletionHandler:^(NSArray *achievements, NSError *error)

    {
        if (error == nil)
        {
            for (GKAchievement* achievement in achievements)
                [achievementsDictionary setObject: achievement forKey: achievement.identifier];
        }
    }];

Solution

  • If you're wanting the data that describes the achievements (the stuff entered into iTunes Connect), then you want loadAchievementDescriptionsWithCompletionHandler:. If you want the current player's achievements then your code should work, but if the player has no achievements you will get nil (rather than array of uncompleted achievements).