Update matchData in GKTurnBasedMatch without completing the rotation

GameKit seems to only allow GKTurnBasedMatch be updated once during the time that GKTurnBasedMatch downloaded from Game Center servers. Is there any other way to update the matchData property?

+4
source share
2 answers

The following method has been added to GKTurnBasedMatch in iOS 6.0 and will do what you need:

 - (void)saveCurrentTurnWithMatchData:(NSData *)matchData completionHandler:(void (^)(NSError *error))completionHandler 

"Update match data without promoting the game to another player"

+1
source

You can call `-

 [GKTurnBasedMatch (void)loadMatchDataWithCompletionHandler:(void (^)(NSData *matchData, NSError *error))completionHandler]; 

as often as you like getting updated matchData. If you want to do incremental moves, you can also do -

 [GKTunrBasedMatch - (void)endTurnWithNextParticipant:(GKTurnBasedParticipant *)nextParticipant matchData:(NSData *)matchData completionHandler:(void (^)(NSError *error))completionHandler]; 

with your own member as the next member. However, you need to load the MatchDataWithCompletionhandler: once again after you have sent a partial move before you are allowed to send the next part of the move.

+4
source

Source: https://habr.com/ru/post/1385817/


All Articles