When I test my game the score of my game ends in a time of 3.49 seconds, but in gamecenter the score that shows up in the leaderboards is 1:01:52.76. I think the problem is that i get a yellow flag that says incompatible integer to integer conversion assigning to int_64 (aka long long) from NSString. Here is the part of the code that shows the error.
- (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