有没有办法在对象GKScore中存储int值?

时间:2014-06-23 15:33:42

标签: ios objective-c xcode game-center

我正在尝试将Gamecenter集成到我的应用中,但我似乎无法让它工作:

- (void) reportScore {
GKScore *score = [[GKScore alloc] initWithLeaderboardIdentifier:@"High_Scores_LeaderBoard"];

[GKScore reportScores:@[score] withCompletionHandler:^(NSError *error) {
    if (error != nil) {
        NSLog(@"%@", [error localizedDescription]);
    }
}];

}

我使用上述方法向游戏中心报告得分。但是我把我的分数存储在这个int中:

extern int g_nScore;

我有办法将g_nScore存储为GKScore,以便我可以运行上述方法吗?

1 个答案:

答案 0 :(得分:0)

GKScore has a "value" property,这是一个“int64_t”。

为什么不将“.value”对象的“score”属性设置为“g_nScore”?