0
當我測試我的遊戲時,我的遊戲得分在3.49秒時間內結束,但在gamecenter中,排行榜中顯示的得分是1:01:52.76。我認爲問題是我得到一個黃色的標誌,說不兼容整數到整數轉換分配給來自NSString int_64(又名長)。以下是顯示錯誤的代碼部分。Gamecenter得分未提交正確分數
- (IBAction)buttonPressed:(id)sender {
[self startTimer];
count--;
countLabel.text = [NSString stringWithFormat:@"Score\n%i", count];
// 2
if (count == 0) {
[self.stopWatchTimer invalidate];
timeLabel.hidden = YES;
// Create date from the elapsed time
NSDate *currentDate = [NSDate date];
NSTimeInterval timeInterval = [currentDate timeIntervalSinceDate:self.startDate];
NSDate *timerDate = [NSDate dateWithTimeIntervalSince1970:timeInterval];
// Create a date formatter
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"'Your time: 'ss.SSS"];
[dateFormatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0.0]];
// Format the elapsed time and set it to the label
NSString *timeString = [dateFormatter stringFromDate:timerDate];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Time is up!"
message: timeString
delegate:self
cancelButtonTitle:@"Play Again"
otherButtonTitles:@"Level Select",nil];
[alert show];
if (count == 0) {
GKScore *scoreReporter = [[GKScore alloc] initWithLeaderboardIdentifier:@"tap_novice"];
scoreReporter.value = timeString;
scoreReporter.context = 0;
NSArray *scores = @[scoreReporter];
[GKScore reportScores:@[scoreReporter] withCompletionHandler:^(NSError *error) {
if (error == nil) {
NSLog(@"Score reported successfully!");
} else {
NSLog(@"Unable to report score!");
}
}];
}
}
}
@end
請了投票這一點,並選擇它作爲回答。 – WMios