アプリ ストアに小さなゲームがあり、ゲーム キットのリーダーボードを使用しています。Xcode ドキュメントからのコード。
- (void) reportScore: (int64_t) score forCategory: (NSString*) category {
if (!auth_ok)
return;
Class gcClass = (NSClassFromString(@"GKScore"));
GKScore *scoreReporter = [[[gcClass alloc] initWithCategory:category] autorelease];
scoreReporter.value = score;
[scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {
if (error != nil) {
NSLog(@"%@",error);
}
else {
NSLog(@"reportScore ok!");
}
}];
}
それは決してうまくいかない。しかし、今日、私はこのプロジェクトをビルドする Xcode 3.2.5 を使用しています。他のコードを変更すると、GKScore レポートのスコアが間違っていることがわかりました。reportScore メッセージを次のように呼び出します。
int winCount=15;
[gameView reportScore:winCount forCategory:@"memory.iphone.wincount"];
結果は value=761228871165046176 です。