我在这里有点未知,真的不知道这是否有问题。我正在尝试使用以下代码退出回合制游戏:
[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”并且不知道该怎么做。