我在这里有点不知名,并不知道这是不是错了。我试图使用以下代码退出回合制游戏:
[match participantQuitInTurnWithOutcome:GKTurnBasedMatchOutcomeQuit
nextParticipants:[_match.participants objectAtIndex:1]
turnTimeout:GKTurnTimeoutDefault
matchData:match.matchData
completionHandler:^(NSError *error) {
if (error)
NSLog(@"Error while quitting match: %@", error.localizedFailureReason);
}];
但在测试时会收到以下消息:
退出匹配时出错:(null)
这是我第一次测试这个并且需要一些错误信息,或者有人可能暗示我。
干杯
更新
我已经搜索了互联网(再次)并找到了我正在测试的IOS6(http://www.raywenderlich.com/forums/viewtopic.php?f=13&t=5244)的一些代码:
// load all of the matches the player is currently a part of
[GKTurnBasedMatch loadMatchesWithCompletionHandler:^(NSArray *matches, NSError *error)
{
if (error) NSLog(@"Error loading matches: %@", error);
// create some placeholder match data
NSString *matchString = @"Deleting match";
NSData *matchData = [matchString dataUsingEncoding:NSUTF8StringEncoding];
// for each match
for (GKTurnBasedMatch *match in matches)
{
// log the id of the match
NSLog(@"ID of match we are removing: %@", match.matchID);
// for each player we set their outcome to 'tied'
for (GKTurnBasedParticipant *participant in match.participants)
participant.matchOutcome = GKTurnBasedMatchOutcomeTied;
// end the match
[match endMatchInTurnWithMatchData:matchData completionHandler:^(NSError *error)
{
if (error) NSLog(@"Error ending the match: %@", error);
// and then remove it
[match removeWithCompletionHandler:^(NSError *error)
{
if (error) NSLog(@"Error removing match: %@", error);
}];
}];
}
}];
现在似乎工作但我得到:GKErrorDomain Code = 24,这似乎意味着“GKErrorTurnBasedInvalidState = 24”并且不知道该怎么做。