Search code examples
objective-cxcode4

How to get game center achievements description


How to get game center achievements description into NSString?


Solution

  • Apple makes it very nice for you with this simple block method:

    - (void) retrieveAchievmentMetadata {
    [GKAchievementDescription loadAchievementDescriptionsWithCompletionHandler:
        ^(NSArray *descriptions, NSError *error) {
            if (error != nil)
                // process the errors
            if (descriptions != nil)
                // use the achievement descriptions.
        }];
    }
    

    You can then extract the NSStrings from the descriptions array.

    There is more documentation on this topic here: http://developer.apple.com/library/ios/#DOCUMENTATION/NetworkingInternet/Conceptual/GameKit_Guide/Achievements/Achievements.html

    I hope this helps!