我在GKTurnBasedMatch中实现了GKAchievement,它最初工作。 现在我在报告其他玩家的成就时遇到此错误。有趣的是,同样的代码授予本地玩家
的成就Terminating app due to uncaught exception 'GKInvalidArgumentException', reason: 'A GKAchievement can only be submitted for another player when ending a turn-based match.'
这是我用于报告GKAchievement的代码
GKAchievement *achievement = [[GKAchievement alloc] initWithIdentifier:identifier forPlayer:playerID];
if(achievement) {
achievement.percentComplete = percent;
achievement.showsCompletionBanner = YES;
[GKAchievement reportAchievements:@[achievement]
withCompletionHandler:^(NSError *error) {
if(error) {
NSLog(@"Unable to report achievement: %@", error);
}
completion(nil);
}];
}
这是结束GKTurnBasedMatch
的代码 [self.gkMatch endMatchInTurnWithMatchData:archivedData
completionHandler:^(NSError *error) {
if(!error) {
NSLog(@"Awarding Achievement to %@", [self getWinner].log);
NSString *winnerPlayerId = [self getWinner].playerId;
[self awardAchievement:@"someAchievement" to:winnerPlayerId percentCompleted:100.0 completion:^(NSError *error1) {
completion(error1);
}];
} else {
NSLog(@"endMatchInTurnWithMatchData %@", error);
}
}];
帮助我。
感谢。