1

I've been trying for hours and I cannot get this to work, in my GameCenterManager class I've got this:

- (void) retrieveAchievmentMetadata {
self.achievementsDescDictionary = [[NSMutableDictionary alloc] init];

[GKAchievementDescription loadAchievementDescriptionsWithCompletionHandler:
 ^(NSArray *descriptions, NSError *error) {
     if (error != nil) {
         NSLog(@"Error %@", error);

     } else {
         if (descriptions != nil){
             for (GKAchievementDescription* a in descriptions) {
                 [achievementsDescDictionary setObject: a forKey: a.identifier];
                 NSLog(@"identifier %@", a.identifier);
             }
             NSLog(@"count %i", [achievementsDescDictionary count]);
         }
     }
 }];

}

It all works, the output is good, the count is good but when I try to call it to get a GKAchievementDescription from another class it always returns (null) and the count is 0.

NSLog(@"count %i", [gameCenterManager.achievementsDescDictionary count]);
if (gameCenterManager.achievementsDescDictionary == NULL) {
    NSLog(@"ERROR");
}

I'm going crazy with this, any help will be great. Thanks.

GuiyeC
  • 116
  • 8

1 Answers1

0

May be a problem with the self from self.achievementsDescDictionary

Use in the .h

@property (retain) NSMutableDictionary* achievementsDescDictionary;

And on the .m

@synthesize achievementsDescDictionary;
...
achievementsDescDictionary = [[NSMutableDictionary alloc] init];
Benoît Freslon
  • 2,021
  • 4
  • 26
  • 35