2012-12-26 69 views
0

我碰到一個SIGABRT崩潰,有時會說崩潰:一個GKScore必須包含一個初始化值。GKScore必須包含初始值?

因此,跟蹤它到這條線:

[localScore reportScoreWithCompletionHandler:^(NSError* error) {}]; 

而且localStore是這樣創建的:

GKScore* localScore = [scores objectForKey:category]; 

- 類來自...

for (NSString* category in categories) 

- - 類別來自...

[GKLeaderboard loadCategoriesWithCompletionHandler:^(NSArray *categories, NSArray *titles, NSError *error) 

-(void) initScores 
{ 
    NSString* libraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0]; 
    NSString* file = [libraryPath stringByAppendingPathComponent:currentPlayerID]; 
    file = [file stringByAppendingString:kScoresFile]; 
    id object = [NSKeyedUnarchiver unarchiveObjectWithFile:file]; 

    if ([object isKindOfClass:[NSMutableDictionary class]]) 
    { 
     NSMutableDictionary* loadedScores = (NSMutableDictionary*)object; 
     scores = [[NSMutableDictionary alloc] initWithDictionary:loadedScores]; 
    } 
    else 
    { 
     scores = [[NSMutableDictionary alloc] init]; 
    } 

    //NSLog(@"scores initialized: %d", scores.count); 
} 

對不起,所有的代碼,但幾乎所有這些代碼都來自這個庫文件:https://github.com/csddavies/DDGameKitHelper/blob/master/DDGameKitHelper.m

反正我將如何解決這一問題?

謝謝!

+0

從哪裏來的分數陣列? – rickster

+0

我已添加該信息! :)哎呀抱歉,你說分數陣,我以爲你說的是​​分類。我會在一分鐘內補充一點。 –

+0

好吧,我現在添加了這個信息 –

回答

2

GameKit reference

要報告比分遊戲中心,遊戲分配和初始化一個新對象時,value屬性設置爲玩家獲得的分數,然後調用reportScoreWithCompletionHandler:方法。

最有可能的抱怨,因爲您沒有設置value屬性,但它也有可能是你缺少的第一步太 - 也就是說,它並不像你提交,從排行榜來到GKScore對象而不是你自己創建的。

+0

這就是我正在計算,我修好了! –

相關問題