2012-07-16 51 views
1

我一直在尝试了几个小时,我不能得到这个工作,我GameCenterManager类我有这样的:loadAchievementDescriptionsWithCompletionHandler,总的NSMutableDictionary空

- (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]); 
     } 
    } 
}]; 

}

它的所有作品中,输出为好,算好,但是当我尝试调用它来获得从其它类,它总是返回(空)一GKAchievementDescription和计数为0

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

我要疯了,任何帮助都会很棒。谢谢。

回答

0

可能与self.achievementsDescDictionary

使用在.H

@property (retain) NSMutableDictionary* achievementsDescDictionary; 

而且在.M自身问题

@synthesize achievementsDescDictionary; 
... 
achievementsDescDictionary = [[NSMutableDictionary alloc] init];