0

アプリを持っていて、ゲームセンターにスコアを送信しようとしています。これは私のコードです:

- (IBAction) submitScore{

NSString *show = [[NSString alloc] initWithFormat:@"Note: Scores may take some time to update"];
self.note.text = show;

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Submitted"
                                                message:@"Your score has been submitted to the Gamecenter leaderboard"
                                               delegate:nil
                                      cancelButtonTitle:@"OK"
                                      otherButtonTitles: nil];
[alert show];


array = [NSMutableArray arrayWithContentsOfFile:Path];


NSString *s = [[NSNumber numberWithInteger:[array count]] stringValue];
NSString *denom = [NSString stringWithFormat: @"%d", 15];;
double resultInNum;
double sdouble = [s doubleValue];
double denomdouble = [denom doubleValue];



resultInNum = sdouble/denomdouble * 100;

if(resultInNum > 0)
{
    self.currentLeaderBoard = kLeaderboardID;

    [self.gameCenterManager reportScore: resultInNum forCategory: self.currentLeaderBoard];
    Submit.enabled = NO;



}
array = [NSMutableArray arrayWithContentsOfFile:Path];



[array writeToFile:Path atomically:YES];
NSLog(@"Count: %i", [array count]);

しかし、私がそれをしようとすると、リーダーボードに送信されません。デバッガーで受け取ったエラーはありません。複数のリーダー ボードを追加するまでは機能していました。ここで何が問題なのですか?

4

2 に答える 2

0

スコア値は int64_t でなければなりません。

そして、値を直接割り当てる代わりに NSStrings を使用している理由がわかりませんか?

于 2012-08-18T23:24:01.467 に答える
0

スコアを送信するための正しいコードを実行していることを確認してください。これは私がとても気に入っている方法です。iOS 7 で使用してほしくないという警告が表示されますが、それでも機能します。うまくいかない場合はお知らせください。

(IBAction)submitscoretogamecenter{

GKLocalPlayer *localplayer = [GKLocalPlayer localPlayer];
[localplayer authenticateWithCompletionHandler:^(NSError *error) {

}];
//This is the same category id you set in your itunes connect GameCenter LeaderBoard
GKScore *myScoreValue = [[[GKScore alloc] initWithCategory:@"insertCategory"] autorelease];
myScoreValue.value = scoreInt;

[myScoreValue reportScoreWithCompletionHandler:^(NSError *error){

    //insert what happens after it's posted 

}];
[self checkAchievements];

}

于 2014-04-13T13:25:01.093 に答える