iOS-沙箱中的rematchWithCompletionHandler问题 [英] iOS - issue with rematchWithCompletionHandler in Sandbox
问题描述
我有以下代码:
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对它进行Beta测试,但是由于某些原因,在尝试重新匹配时出现以下错误:
I've got a number of people Beta testing it via TestFlight with sandbox enabled, but for some reason I get the following error when trying to rematch:
{GKServerStatusCode = 5121,NSLocalizedDescription =所请求的操作无法完成,因为播放器无效.,NSUnderlyingError = 0x17045cdd0该操作无法完成.status = 5121,邀请从:224002977到:225851510不允许,因为他们既不是朋友,也不是最近玩过}
比赛已正确结束,所以不是这样:
The match was ended properly, so it's not that:
[_match
endMatchInTurnWithMatchData:data
scores:scores
achievements:nil
completionHandler:^(NSError *error) {}];
我认为这是Sandbox的一个孤立问题,但是除非我可以对其进行测试,否则我不确定它是否会在发布后起作用.
I'm thinking this is an isolated issue with Sandbox, but unless I can test it I'm not confident that it will work in the once released.
这是tappedItem.match对象:
Here's the tappedItem.match object:
<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)>
如您所见,这场比赛是在几个小时前完成的.只要他们是朋友,此方法就可以正常工作,但是我需要先测试重新匹配功能,然后才能将其投入使用.
So as you can see, the match was only finished a few hours ago. This works as expected as long as they are friends, but I need to test the rematch functionality before I can put it live.
使用findMatchForRequest时,我得到相同的错误代码:
I get the same error code when I use findMatchForRequest:
GKMatchRequest *request = [[GKMatchRequest alloc] init];
if(player != NULL)
request.recipients= [NSMutableArray arrayWithObject:player];
request.minPlayers = 2;
request.maxPlayers = 2;
根据错误,他们既不是朋友,也不是最近玩过",但他们最近才玩过.
According to the error, "they are neither friends nor have recently played", yet they have played recently.
推荐答案
我在这里抓住稻草,但是您的编辑看起来与我在GKTurnBasedMatchTurn末尾尝试构建nextParticipant数组时遇到的问题类似. href ="https://stackoverflow.com/questions/28522794/gamecenter-endturnwithnextparticipants-not-advancing"> GameCenter:endTurnWithNextParticipants无法推进.它并没有给我带来连贯的错误,只是不断将回合发送给同一位玩家.根源似乎是:Game Center不喜欢它,因为您将它传递给以前发送给您的非可变对象的指针.
I am grasping at straws here, but your edit looks similar to a problem I wrestled with trying to build the array of nextParticipants at the end of a GKTurnBasedMatchTurn GameCenter: endTurnWithNextParticipants not advancing. It didn't give me a coherent error, it just kept sending the turn back to the same player. The root seemed to be: Game Center does not like it when you pass it pointers to non-mutable objects that it previously sent to you.
我不得不改变
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)
{
您的代码块不会显示您从何处获得播放器,因此对于这些对象是新对象还是重复使用的对象,我不清楚.我想知道这段代码
Your code blocks don't show where you're getting player from, so it's not clear to me if these are new or re-used objects. I'm wondering if this code
if(tappedItem.match.status == GKTurnBasedMatchStatusEnded){
[[GameKitHelper sharedGameKitHelper] findMatchWithViewController:self delegate:self debug:false invite:tappedItem.player];
和此代码
if(player != NULL)
request.recipients= [NSMutableArray arrayWithObject:player];
是问题所在.如果您尝试创建播放器的副本并将其传递给rematch和findMatch调用,会发生什么情况?
are the problem. What happens if you try creating copies of the player and pass that to the rematch and findMatch calls?
这篇关于iOS-沙箱中的rematchWithCompletionHandler问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!