iOS - issue with rematchWithCompletionHandler in Sandbox

╄→гoц情女王★ 提交于 2019-12-06 16:44:28
Thunk

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.

I had to change

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

To:

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];

and this code

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

are the problem. What happens if you try creating copies of the player and pass that to the rematch and findMatch calls?

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!