Updating the matchData in a GKTurnBasedMatch without ending the turn

旧巷老猫 提交于 2019-12-09 18:38:27

问题


It seems that GameKit only allows GKTurnBasedMatch to be updated once per time that GKTurnBasedMatch is loaded from the Game Center servers. Is there an other way to update the matchData property?


回答1:


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

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

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




回答2:


You can call `-

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

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

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

with your own participant as next participant. However, you have to loadMatchDataWithCompletionhandler: once again after you submitted your partial move before you are allowed to submit the next move part.



来源:https://stackoverflow.com/questions/8469093/updating-the-matchdata-in-a-gkturnbasedmatch-without-ending-the-turn

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