iOS-沙盒中rematchWithCompletionHandler存在问题
我有以下代码:iOS-沙盒中rematchWithCompletionHandler存在问题,ios,game-center,Ios,Game Center,我有以下代码: if(tappedItem.match.status == GKTurnBasedMatchStatusEnded){ [[GameKitHelper sharedGameKitHelper] findMatchWithViewController:self delegate:self debug:false invite:tappedItem.player]; return; NSLog(@"Participants %@
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对其进行测试,但由于某些原因,我在尝试重新匹配时出现以下错误:
{GKServerStatusCode=5121,NSLocalizedDescription=由于播放机无效,请求的操作无法完成。NSUnderlyingError=0x17045cdd0“操作无法完成。status=5121,不允许从:224002977到:2258515110的邀请,因为他们既不是朋友,也不是最近玩过的游戏。”
比赛结束得很顺利,所以不是这样:
[_match
endMatchInTurnWithMatchData:data
scores:scores
achievements:nil
completionHandler:^(NSError *error) {}];
我认为这是沙盒的一个孤立问题,但除非我能测试它,否则我不相信它会在发布后的版本中工作
编辑#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)>
根据错误,“他们既不是朋友,也不是最近玩过的”,但他们最近玩过。我在这里抓住了救命稻草,但您的编辑看起来类似于我在GKTurnBasedMatchTurn结束时尝试构建下一个参与者阵列时遇到的问题。它没有给我一个连贯的错误,它只是不断地把转身传给同一个球员。根源似乎是:当您将指向它以前发送给您的不可变对象的指针传递给它时,Game Center不喜欢它 我得换衣服
NSMutableArray *nextPlayers = (NSMutableArray *)theMatch.participants;
..some sorting logic deleted for brevity...
[theMatch endTurnWithNextParticipants:nextPlayers
turnTimeout:GKTurnTimeoutDefault
matchData:updatedMatchData
completionHandler:^(NSError *error)
{
致:
您的代码块没有显示从哪里获得player,因此我不清楚这些是新的还是重复使用的对象。我想知道这个代码
if(tappedItem.match.status == GKTurnBasedMatchStatusEnded){
[[GameKitHelper sharedGameKitHelper] findMatchWithViewController:self delegate:self debug:false invite:tappedItem.player];
if(player != NULL)
request.recipients= [NSMutableArray arrayWithObject:player];
这个密码呢
if(tappedItem.match.status == GKTurnBasedMatchStatusEnded){
[[GameKitHelper sharedGameKitHelper] findMatchWithViewController:self delegate:self debug:false invite:tappedItem.player];
if(player != NULL)
request.recipients= [NSMutableArray arrayWithObject:player];
这就是问题所在。如果您尝试创建玩家的副本并将其传递给重赛和findMatch呼叫,会发生什么情况?当您记录参与者时,您会得到什么?比赛的参与者与预期的一样,例如,它知道如何邀请22585110。即使我使用request.recipients=[NSMutableArray arrayWithObject:player]执行标准邀请;它也有同样的问题。有趣的是,我不确定这是我面临的问题,但我会看看这是否有帮助。编辑-不。如果他们是朋友,一切都很好。问题是当他们不是朋友时,根据错误,我没有和我要重婚的人玩过游戏。我几乎确信这可能是一个沙箱问题,除非其他人能提供更多信息。