[英]The connection to service named com.apple.fonts was invalidated on xcodebuild -resolvePackageDependencies
[英]endMatchInTurnWithMatchData resulting in “The connection to service named com.apple.gamed was interrupted”
我對endMatchInTurnWithMatchData的調用導致連接服務中斷的錯誤。 關於尋找什么來診斷此問題的任何提示? Xcode 7.3.1,部署目標9.3
-(void)sendGameOver {
GKTurnBasedMatch *currentMatch = [[GameKitHelper sharedGameKitHelper] currentMatch];
// set the game outcome property for the current participant
GKTurnBasedMatchOutcome otherOutcome;
if (self.youAre == game.winningPlayer) {
[currentMatch.currentParticipant setMatchOutcome:GKTurnBasedMatchOutcomeWon];
otherOutcome = GKTurnBasedMatchOutcomeLost;
} else {
[currentMatch.currentParticipant setMatchOutcome:GKTurnBasedMatchOutcomeLost];
otherOutcome = GKTurnBasedMatchOutcomeWon;
}
// all other (only one other) participants get opposite outcome
for (GKTurnBasedParticipant *nextParticipant in currentMatch.participants) {
if (![nextParticipant isEqual:currentMatch.currentParticipant]) {
[nextParticipant setMatchOutcome:otherOutcome];
}
}
// prepare match data
NSDictionary *turn = [NSDictionary dictionaryWithObjects:@[game]
forKeys:@[gameKey]];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:turn];
NSArray *achievements = [self achievementsToReport:currentMatch];
NSArray *scores = [self scoresToReport:currentMatch];
[currentMatch endMatchInTurnWithMatchData:data scores:scores achievements:achievements completionHandler:^(NSError * _Nullable error) {
if (error) {
NSLog(@"%@", error);
[self setGamePopUpMessage:@"Oops, there was a problem. Try that again."];
}
}];
}
不知何故,問題似乎出在成就報告之內。 如果我發送空數組以獲取成就,則錯誤消失了。 但是,當我嘗試通過endMatch傳遞成就信息時,錯誤又回來了。
因此,如果繼續使用,我將繼續收到錯誤消息“到名為com.apple.gamed的服務連接中斷”
endMatchInTurnWithMatchData: scores: achievements: completionHandler:
但是,如果我使用(作為一種解決方法)
endMatchInTurnWithMatchData: completionHandler:
緊隨其后的是:
GKAchievement reportAchievements: withCompletionHandler:
那么一切似乎都可以正常工作。
最初的問題是,我在所有情況下都使用GKAchievement initWithIdentifire自己創建了一系列成就,即使對於以前在比賽中已經報告過的成就也是如此。 正確的方法是先調用loadAchievementsWithCompletionHandler來獲取玩家已知的所有成就,然后更新相關成就。 如果需要,可以將新的GKAchievement添加到該陣列。 但是關鍵是正確初始化數組。 修復所有問題后,我可以使用endMatchInTurnWithMatchData正確發送成就數組:scores:Achievement:completedler :,並且不再收到我的原始錯誤“連接服務com.apple.gamed被中斷”。
然而...
我的游戲是兩人游戲,因此有人可能被迫轉彎(或不小心轉彎),使他們立即輸掉。 在這種情況下,我想增加他們的對手(剛剛贏得比賽)的成就。 但是,您似乎無法增加對手的成就,因為您不知道對方的成就水平。
我的解決方法是不理想的,因為在轉牌中輸掉游戲的玩家報告了他們可能獲得的任何成就(暫時沒有,但您永遠不知道...。)。 獲勝的玩家(輪到其不是),將在收到“ matchEnded”消息后報告其成就。 不幸的是,這意味着如果他們從不打開游戲,他們將不會增加成就。 不理想。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.