iOS – 沙盒中的rematchWithCompletionHandler问题

我有以下代码:

if(tappedItem.match.status == GKTurnBasedMatchStatusEnded){ [[GameKitHelper sharedGameKitHelper] findMatchWithViewController:self delegate:self debug:false invite:tappedItem.player]; return; NSLog(@"Participants %@", [tappedItem.match.participants description]); [tappedItem.match rematchWithCompletionHandler:^(GKTurnBasedMatch *match, NSError *error) { if (error) { NSLog(@"%@", error); } else { [[GameKitHelper sharedGameKitHelper] setMatch:tappedItem.match]; [[NSNotificationCenter defaultCenter] postNotificationName:ShowGameScreen object:tappedItem.match]; } }]; } 

我有很多人通过TestFlight Betatesting它,并启用了沙箱,但由于某种原因,我尝试重新匹配时遇到以下错误:

{GKServerStatusCode = 5121,NSLocalizedDescription =请求的操作无法完成,因为播放器是无效的,NSUnderlyingError = 0x17045cdd0“操作无法完成状态= 5121, 邀请:224002977至:225851510是不允许的,因为它们是没有朋友也没有最近玩过 “}

比赛结束了,所以不是这样的:

 [_match endMatchInTurnWithMatchData:data scores:scores achievements:nil completionHandler:^(NSError *error) {}]; 

我认为这是一个与沙盒孤立的问题,但除非我可以testing它,我不相信它会在一旦发布。

编辑#2:

这里是tappedItem.match对象:

  <GKTurnBasedMatch 0x174250200 - matchID:0049f124-b8c3-43d8-9964-beaf58af69f8 bundleID:--- REMOVED --- status:GKTurnBasedMatchStatusEnded message:'' creationDate:2015-06-24 23:12:31 +0000 currentParticipant:(null) participants:<GKTurnBasedParticipant 0x174205450 - playerID:G:225851510 status:Done matchOutcome:Won lastTurnDate:2015-06-24 23:12:32 +0000 timeoutDate:(null)>, <GKTurnBasedParticipant 0x174205460 - playerID:G:224002977 (local player) status:Done matchOutcome:Lost lastTurnDate:2015-06-24 23:16:56 +0000 timeoutDate:(null)> matchData.length:295 matchDataMaximumSize:65536 exchanges:(null)> 

正如你所看到的,这场比赛只是几个小时前才完成的。 只要他们是朋友,就可以按预期工作,但是我需要在复活之前testing复赛function。

编辑#1:

当我使用findMatchForRequest时,我得到相同的错误代码:

 GKMatchRequest *request = [[GKMatchRequest alloc] init]; if(player != NULL) request.recipients= [NSMutableArray arrayWithObject:player]; request.minPlayers = 2; request.maxPlayers = 2; 

根据这个错误,“他们既不是朋友也不是最近玩过的”,但是他们最近玩过了。

我在这里抓住吸pipe,但是你的编辑看起来类似于我试图在GKTurnBasedMatchTurn GameCenter结束时构buildnextParticipants数组的一个问题:endTurnWithNextParticipants没有前进 。 它没有给我一个连贯的错误,它只是不断发送回到同一个球员。 根似乎是:当您将指针传递给之前发送给您的非可变对象时,Game Center不喜欢它。

我必须改变

 NSMutableArray *nextPlayers = (NSMutableArray *)theMatch.participants; ..some sorting logic deleted for brevity... [theMatch endTurnWithNextParticipants:nextPlayers turnTimeout:GKTurnTimeoutDefault matchData:updatedMatchData completionHandler:^(NSError *error) { 

至:

 NSMutableArray *nextParticipants = [NSMutableArray new]; for (GKTurnBasedParticipant *participant in theMatch.participants) { ...some sorting logic deleted for brevity... [nextParticipants addObject:participant]; } [theMatch endTurnWithNextParticipants:nextParticipants turnTimeout:GKTurnTimeoutDefault matchData:updatedMatchData completionHandler:^(NSError *error) { 

你的代码块不会显示你从哪里得到玩家 ,所以我不清楚这些是新的还是重用的对象。 我想知道如果这个代码

 if(tappedItem.match.status == GKTurnBasedMatchStatusEnded){ [[GameKitHelper sharedGameKitHelper] findMatchWithViewController:self delegate:self debug:false invite:tappedItem.player]; 

和这个代码

 if(player != NULL) request.recipients= [NSMutableArray arrayWithObject:player]; 

是问题。 如果您尝试创build播放器的副本并将其传递给重新匹配和findMatch调用,会发生什么情况?