gpt4 book ai didi

iOS - 沙盒中重新匹配 WithCompletionHandler 的问题

转载 作者:行者123 更新时间:2023-11-29 12:20:01 25 4
gpt4 key购买 nike

我有以下代码:

   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 测试,但由于某种原因,我在尝试重新匹配时遇到以下错误:

{GKServerStatusCode=5121, NSLocalizedDescription=The requested operation could not be completed because the player is invalid., NSUnderlyingError=0x17045cdd0 "The operation couldn’t be completed. status = 5121, Invitation from: 224002977 to: 225851510 is not allowed because they are neither friends nor have recently played"}

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

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

我认为这是 Sandbox 的一个孤立问题,但除非我可以对其进行测试,否则我不确定它是否会在发布后正常工作。

编辑#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)>

如您所见,比赛才在几个小时前结束。只要他们是 friend ,这就会按预期工作,但我需要先测试重新匹配功能,然后才能上线。

编辑#1:

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

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

根据错误,“他们既不是 friend 也不是最近玩过”,但他们最近玩过。

最佳答案

我在这里捕获了救命稻草,但您的编辑看起来类似于我在 GKTurnBasedMatchTurn GameCenter: endTurnWithNextParticipants not advancing 末尾尝试构建 nextParticipants 数组时遇到的问题。 .它没有给我一个连贯的错误,它只是不断地把转牌发回给同一个玩家。根源似乎是:Game Center 不喜欢您将指向它之前发送给您的不可变对象(immutable对象)的指针传递给它。

我不得不改变

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)
{

你的代码块没有显示你从哪里得到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 调用,会发生什么情况?

关于iOS - 沙盒中重新匹配 WithCompletionHandler 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30922003/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com