2012-07-16 54 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];